示例#1
0
 def loadFromWeb(self, ip, uploadFilename, uploadFile):
     """
     Create a wms based on a uploaded zip file.
     
     ip: remote address
     uploadFilename: upload user name of file (string)
     uploadFile: uploaded user file (file pointer made available by WSGI server)
     """
     helper.dbg("Filename was: " + uploadFilename )
     self.ip = ip
     self.uuid =  uuid.uuid4().hex
     self.zfilename = uploadFilename
     self.zfiledata = uploadFile
     self.extractdir = os.path.join (configuration.getDataDir(), self.uuid)
     self.zfilepath = os.path.join (self.extractdir, self.zfilename)
     self.time = time.strftime('%d%m%y-%H:%M:%S')
     self._savefile()
     self.rasters = [] # list of probe results for rasters
     self.vectors = [] # list of probe results for vectors
     f = geozip.GeoZip(self.zfilepath)
     if f.check_integrity() == False:
         raise IOError("Checksum error: zipfile is corrupted")
     #extract all files under extractdir
     f.extract(self.extractdir)
     #group by name
     f.group_files()
     #probe all the properties of geotiffs
     self.rasters = [ helper.probedata(x) for x in f.getGeoTiffFiles() ]
     self.vectors = [ helper.probedata(x) for x in f.getShapeFiles() ]
     helper.dbg("Extracted RASTERS: " + `self.rasters`)
     helper.dbg("Extracted VECTORS: " + `self.vectors`)
     self.datasetname = helper.getBaseName(self.zfilename)
     self.layers = self.rasters + self.vectors
     self._addlayersid()
     self.wms_md = { "title": self.datasetname , "Language" : "ENG", "Keywords":"IGIBS, View Service", "Fees": "N/A", "protected": self.protected, "extent": [ -7.55645, 49.76688, 3.6342, 61.465701 ], "projection" : "epsg:4326" }
     helper.dbg("DatasetName: " + `self.datasetname`)
     helper.dbg("zfilename: " + `self.zfilename`)
示例#2
0
 def loadFromURL(self, ip, url):
     """
     Create a media object sessions and also loads the metadata from the file based on a uploaded file.
     
     ip: remote address
     url: url of the file (string)
     """
     self.ip = ip
     self.uuid =  uuid.uuid4().hex
     # assuming filename is eveything after the rightmost `/'        
     self.filename = helper.strfilter( url[url.rfind('/'):] ,"\\/" )
     self.filedata = urllib.urlopen(url)
     self.filedir = os.path.join (configuration.getDataDir(), self.uuid)
     self.filefullpath = os.path.join (self.filedir, self.filename)
     self.ctime = time.strftime('%d%m%y-%H:%M:%S')
     self.customtags = {}
     self.mtime = self.ctime
     self._savefile()
     self.mediamd = helper.probedata(self.filefullpath)
     self.datasetname = helper.getBaseName(self.filename)
     db.insert_uuid(self.uuid)
     log.debug("filename: " + `self.filename`)
     log.debug("DatasetName (filename w/o extention): " + `self.datasetname`)
示例#3
0
 def loadFromFile(self, uuid, group="ALL"):
     """
     Create a media object based on a saved session.
     
     uuid: the uuid corresponding to the saved media object instance
     @exceptions: file does not exist, parse error
     """
     self.uuid = uuid
     self.filedir = os.path.join (configuration.getDataDir(), self.uuid)
     
     log.debug("loading saved uuid: " + self.uuid)
     sessions_file = open(os.path.join ( self.filedir, 'sessions.json' ), 'r')
     sessions = json.load( sessions_file )
     sessions_file.close()
     if sessions == None:
         raise ValueError("Cannot parse sessions.json for uuid: " + uuid)
     self.ip = sessions["ip"]
     self.datasetname = sessions["datasetname"]
     self.filename = sessions["filename"]
     self.filefullpath = os.path.join (self.filedir, self.filename)
     self.mtime = sessions["mtime"]
     self.ctime = sessions["ctime"]
     self.customtags = sessions["customtags"]
     self.mediamd = helper.probedata(self.filefullpath, group)
示例#4
0
 def loadFromWeb(self, ip, uploadFilename, uploadData):
     """
     Create a media object sessions and also loads the metadata from the file based on a uploaded file.
     
     ip: remote address
     uploadFilename: upload user name of file (string)
     uploadFile: uploaded user file (file pointer made available by WSGI server)
     """
     log.debug("Filename was: " + uploadFilename )
     self.ip = ip
     self.uuid =  uuid.uuid4().hex
     self.filename = uploadFilename
     self.filedata = uploadData
     self.filedir = os.path.join (configuration.getDataDir(), self.uuid)
     self.filefullpath = os.path.join (self.filedir, self.filename)
     self.ctime = time.strftime('%d%m%y-%H:%M:%S')
     self.customtags = {}
     self.mtime = self.ctime
     self._savefile()
     self.mediamd = helper.probedata(self.filefullpath)
     self.datasetname = helper.getBaseName(self.filename)
     db.insert_uuid(self.uuid)
     log.debug("filename: " + `self.filename`)
     log.debug("DatasetName (filename w/o extention): " + `self.datasetname`)