<s> from django . shortcuts import render <EOL> from django . http import HttpResponse <EOL> from django . core . files . base import ContentFile <EOL> from django . core . servers . basehttp import FileWrapper <EOL> import numpy as np <EOL> import urllib2 <EOL> import json <EOL> import re <EOL> from contextlib import closing <EOL> import cStringIO <EOL> from django . conf import settings <EOL> from ocpcaerror import OCPCAError <EOL> import ocpcaproj <EOL> import ocpcadb <EOL> import ocpgraph <EOL> import logging <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> import tempfile <EOL> import tarfile <EOL> import zipfile <EOL> import os <EOL> def getResponse ( filename ) : <EOL> output = tarfile . open ( '<STR_LIT>' , mode = '<STR_LIT:w>' ) <EOL> try : <EOL> output . add ( filename ) <EOL> except Exception , e : <EOL> logger . warning ( "<STR_LIT>" ) <EOL> raise OCPCAError ( "<STR_LIT>" ) <EOL> finally : <EOL> output . close ( ) <EOL> wrapper = FileWrapper ( file ( "<STR_LIT>" ) ) <EOL> response = HttpResponse ( wrapper , '<STR_LIT>' ) <EOL> response [ '<STR_LIT>' ] = <NUM_LIT:5> <EOL> response [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> return response <EOL> def buildGraph ( request , webargs ) : <EOL> arguementType = <NUM_LIT:0> <EOL> try : <EOL> if re . match ( "<STR_LIT>" , webargs ) is not None : <EOL> m = re . match ( "<STR_LIT>" , webargs ) <EOL> [ syntoken , synchan_name ] = [ i for i in m . groups ( ) ] <EOL> arguementType = <NUM_LIT:1> <EOL> elif re . match ( "<STR_LIT>" , webargs ) is not None : <EOL> m = re . match ( "<STR_LIT>" , webargs ) <EOL> [ syntoken , synchan_name , graphType ] = [ i for i in m . groups ( ) ] <EOL> arguementType = <NUM_LIT:2> <EOL> elif re . match ( "<STR_LIT>" , webargs ) is not None : <EOL> m = re . match ( "<STR_LIT>" , webargs ) <EOL> [ syntoken , synchan_name , graphType , Xmin , Xmax , Ymin , Ymax , Zmin , Zmax ] = [ i for i in m . groups ( ) ] <EOL> arguementType = <NUM_LIT:3> <EOL> else : <EOL> logger . warning ( "<STR_LIT>" ) <EOL> raise OCPCAError ( "<STR_LIT>" ) <EOL> except Exception , e : <EOL> logger . warning ( "<STR_LIT>" ) <EOL> raise OCPCAError ( "<STR_LIT>" ) <EOL> with closing ( ocpcaproj . OCPCAProjectsDB ( ) ) as projdb : <EOL> synproj = projdb . loadToken ( syntoken ) <EOL> with closing ( ocpcadb . OCPCADB ( synproj ) ) as syndb : <EOL> synch = synproj . getChannelObj ( synchan_name ) <EOL> if arguementType == <NUM_LIT:1> : <EOL> return getResponse ( ocpgraph . genGraphRAMON ( syndb , synproj , synch ) ) <EOL> elif arguementType == <NUM_LIT:2> : <EOL> return getResponse ( ocpgraph . genGraphRAMON ( syndb , synproj , synch , graphType ) ) <EOL> elif arguementType == <NUM_LIT:3> : <EOL> return getResponse ( ocpgraph . genGraphRAMON ( syndb , synproj , synch , graphType , Xmin , Xmax , Ymin , Ymax , Zmin , Zmax ) ) <EOL> else : <EOL> logger . warning ( "<STR_LIT>" ) <EOL> raise OCPCAError ( "<STR_LIT>" ) </s>
