def get_xml(self, dbName='', acc='', tag='', since=''): self.check_dbName_acc(dbName, acc, since) '''Returns gzipped XML payload. All arguments in get_xml method have default value equal to '' just for avoiding exception if some parameter is missing. For testing: http://webcondvm2:8083/get_xml?dbName=oracle://cms_orcoff_prod/CMS_COND_31X_ECAL&tag=EcalIntercalibConstants_EBg50_EEnoB&since=1; ''' #try: #c = readXML() #db = str(c.dbMap_reverse[dbName]+"/CMS_COND_"+acc) connectionString = getFrontierConnectionString(acc, dbName) shortConnectionString = getFrontierConnectionString(acc, dbName, short=True) vtag = str(tag) vsince = av.get_validated_since(value=since, db=connectionString, tag=vtag, onlyone=False) if len(vsince.split(';')) == 1: xml = SubdetectorFactory.getXMLInstance( dbName=connectionString, tag=vtag, since=vsince, fileType='tar.gz', directory=self.__xmldir, shortName=shortConnectionString) data = xml.get() else: temp = tempfile.TemporaryFile(dir=self.__tmpdir) tar = tarfile.open(mode="w|gz", fileobj=temp) for i in vsince.split(';'): xml = SubdetectorFactory.getXMLInstance( dbName=connectionString, tag=vtag, since=i, fileType='xml', directory=self.__xmldir, shortName=shortConnectionString) name = xml.dump() tar.add(name, arcname=os.path.basename(name), recursive=False) tar.close() temp.seek(0) data = temp.read() cherrypy.response.headers['Content-Disposition'] = \ 'attachment;filename=' + '_'.join([vtag, vsince.replace(';', '_'), '.tar.gz']) #cherrypy.response.headers['Content-Type'] = 'application/x-gzip' cherrypy.response.headers['Content-Encoding'] = 'gzip' return data
def get_xml(self, dbName='', acc='',tag='', since=''): self.check_dbName_acc(dbName, acc, since); '''Returns gzipped XML payload. All arguments in get_xml method have default value equal to '' just for avoiding exception if some parameter is missing. For testing: http://webcondvm2:8083/get_xml?dbName=oracle://cms_orcoff_prod/CMS_COND_31X_ECAL&tag=EcalIntercalibConstants_EBg50_EEnoB&since=1; ''' #try: #c = readXML() #db = str(c.dbMap_reverse[dbName]+"/CMS_COND_"+acc) connectionString = getFrontierConnectionString(acc, dbName) shortConnectionString = getFrontierConnectionString(acc, dbName, short = True) vtag = str(tag) vsince = av.get_validated_since(value = since, db = connectionString, tag = vtag, onlyone = False) if len(vsince.split(';')) == 1: xml = SubdetectorFactory.getXMLInstance(dbName = connectionString, tag = vtag, since = vsince, fileType = 'tar.gz', directory = self.__xmldir, shortName = shortConnectionString) data = xml.get() else: temp = tempfile.TemporaryFile(dir = self.__tmpdir) tar = tarfile.open(mode = "w|gz", fileobj = temp) for i in vsince.split(';'): xml = SubdetectorFactory.getXMLInstance(dbName = connectionString, tag = vtag, since = i, fileType = 'xml', directory = self.__xmldir, shortName = shortConnectionString) name = xml.dump() tar.add(name, arcname = os.path.basename(name), recursive = False) tar.close() temp.seek(0) data = temp.read() cherrypy.response.headers['Content-Disposition'] = \ 'attachment;filename=' + '_'.join([vtag, vsince.replace(';', '_'), '.tar.gz']) #cherrypy.response.headers['Content-Type'] = 'application/x-gzip' cherrypy.response.headers['Content-Encoding'] = 'gzip' return data