コード例 #1
0
    def get_histo(self, dbName='', acc='', tag='', since=''):
        self.check_dbName_acc(dbName, acc, since)
        '''Returns histo. 
        All arguments in get_histo method have default value equal to '' just
        for avoiding exception if some parameter is missing.

        For testing:
        http://HOSTNAME:PORT/get_histo?dbName=oracle://cms_orcoff_prod/CMS_COND_31X_ECAL&tag=EcalIntercalibConstants_EBg50_EEnoB&since=1
        '''

        try:
            tmpdb = self.masker.unmask_dbname(dbName)
            db = av.get_validated_dbname(value=tmpdb,
                                         acc=self.masker.unmask_schema(
                                             tmpdb, acc))
            vtag = av.get_validated_tag(dbName=db, value=tag)
            vsince = av.get_validated_since(value=since.strip(),
                                            db=db,
                                            tag=vtag,
                                            onlyone=True)
            directory = self.__histodir
            histo = SubdetectorFactory.getHistoInstance(dbName=db,
                                                        tag=vtag,
                                                        since=vsince,
                                                        fileType='png',
                                                        directory=directory)
            histoData = histo.get()
        except:
            return 'Tag doesn\'t exist'
        else:
            cherrypy.response.headers['Content-Type'] = 'image/png'
            return histoData
コード例 #2
0
 def get_plot_cmp(self, dbName1 = '', acc1='',tag1 = '', since1 = '1', fileType1 = 'png', png1 = '',
                 dbName2 = '', acc2='',tag2 = '', since2 = '1', fileType2 = 'png', png2 = '', type='3', istkmap = '1'):
     self.check_dbName_acc(dbName1, acc1, since1);
     self.check_dbName_acc(dbName2, acc2, since2);
     if fileType1 != "png" and fileType2 != "png":
         cherrypy.HTTPError(405, "Bad file type !!!!!")
     tmpdb = self.masker.unmask_dbname(dbName1)
     db = av.get_validated_dbname(value = tmpdb, acc = self.masker.unmask_schema(tmpdb, acc1))
     vtag = av.get_validated_tag(dbName = db, value = tag1)
     vsince = av.get_validated_since(value = since1.strip(), db = db, tag = vtag, onlyone = True)
     plot = SubdetectorFactory.getPlotInstance(dbName = db, tag = vtag, since = vsince, 
                                             fileType = fileType1, directory = self.__plotsdir, image = png1)
     img1 = plot.get(get_fname = True)
     tmpdb = self.masker.unmask_dbname(dbName2)
     db = av.get_validated_dbname(value = tmpdb, acc = self.masker.unmask_schema(tmpdb, acc2))
     vtag = av.get_validated_tag(dbName = db, value = tag2)
     vsince = av.get_validated_since(value = since2.strip(), db = db, tag = vtag, onlyone = True)
     plot = SubdetectorFactory.getPlotInstance(dbName = db, tag = vtag, since = vsince, 
                                             fileType = fileType2, directory = self.__plotsdir, image = png2)
     img2 = plot.get(get_fname = True)
     #raise Exception('asdasd'+img2)
     '''if type == '1':
         img3 = ImageChops.subtract(img1, img2, scale=1, offset=128)
     elif type == '2':
         img3 = ImageChops.subtract(img2, img1, scale=1, offset=128)
     elif type == '3':
         img3 =  ImageChops.difference(img1, img2)
     elif type == '4':
         img3 = ImageChops.subtract(img1, img2, scale=1, offset=0)
     else:
         img3 = ImageChops.subtract(img2, img1, scale=1, offset=0)
     '''
     if not os.path.isdir(self.__tmpdir):
         os.makedirs(self.__tmpdir)
     temp = tempfile.TemporaryFile(dir = self.__tmpdir)
     plotTxt = ""
     if re.search('strip', vtag.lower()):
         plotTxt = 'ABSOLUTE DIFFERENCE  (The more lighter colors, the higher the difference.)'
     cmpPNG.CmpTrackerDiff(fileName1 = img1, fileName2 = img2, result = temp,
                txt = plotTxt,
                debug = False)
     #img3.save(temp, 'png')
     temp.seek(0)
     cherrypy.response.headers['Content-Type'] = 'image/' + fileType1
     data = temp.read()
     temp.close()
     return data
コード例 #3
0
 def getAccounts(self, db=""):
     self.check_dbName_acc(db, "31X_ECAL", '1'); 
     dbname = self.masker.unmask_dbname(db = db)
     dbname = av.get_validated_dbname(value = dbname)
     accounts = self.__payloadUserDB.getUsers(dbNameSearch=dbname)
     accounts = [{x[x.keys()[0]]:self.masker.mask_schema(db = dbname, schema = x[x.keys()[0]])} for x in accounts]
     #return str(accounts)
     return self.__condDB_Utils.createJSON('accounts', accounts)
コード例 #4
0
 def getSchemas(self, db="",rn=""):
     self.check_dbName_acc(db, "31X_ECAL", '1');
     dbname = self.masker.unmask_dbname(db = db)
     dbname = av.get_validated_dbname(value = dbname)
     schemas = self.__payloadUserDB.getSchemas(dbNameSearch=dbname) 
     if rn=="vs":
         return self.__condDB_Utils.createJSON('schemas', schemas)
     schemas = [{x[x.keys()[0]]:self.masker.mask_schema(db = dbname, schema = x[x.keys()[0]])} for x in schemas]
     #return str(schemas)
     return self.__condDB_Utils.createJSON('schemas', schemas)
コード例 #5
0
 def get_tag_table(self, dbName, acc):
     self.check_dbName_acc(dbName, acc, '1');
     tmpdb = self.masker.unmask_dbname(dbName)
     tmpacc = self.masker.unmask_schema(tmpdb, acc)
     db = av.get_validated_dbname(value = tmpdb, acc = tmpacc)
     f = open(os.path.join(SubdetectorFactory.getDirectory(dbName = db, 
                             basedir = self.iovTablePath, default = True), self.tag_table_name), 'r')
     data = f.read()
     f.close()
     return data
コード例 #6
0
 def getAccounts(self, db=""):
     self.check_dbName_acc(db, "31X_ECAL", '1')
     dbname = self.masker.unmask_dbname(db=db)
     dbname = av.get_validated_dbname(value=dbname)
     accounts = self.__payloadUserDB.getUsers(dbNameSearch=dbname)
     accounts = [{
         x[x.keys()[0]]:
         self.masker.mask_schema(db=dbname, schema=x[x.keys()[0]])
     } for x in accounts]
     #return str(accounts)
     return self.__condDB_Utils.createJSON('accounts', accounts)
コード例 #7
0
 def getSchemas(self, db="", rn=""):
     self.check_dbName_acc(db, "31X_ECAL", '1')
     dbname = self.masker.unmask_dbname(db=db)
     dbname = av.get_validated_dbname(value=dbname)
     schemas = self.__payloadUserDB.getSchemas(dbNameSearch=dbname)
     if rn == "vs":
         return self.__condDB_Utils.createJSON('schemas', schemas)
     schemas = [{
         x[x.keys()[0]]:
         self.masker.mask_schema(db=dbname, schema=x[x.keys()[0]])
     } for x in schemas]
     #return str(schemas)
     return self.__condDB_Utils.createJSON('schemas', schemas)
コード例 #8
0
 def get_tag_table(self, dbName, acc):
     self.check_dbName_acc(dbName, acc, '1')
     tmpdb = self.masker.unmask_dbname(dbName)
     tmpacc = self.masker.unmask_schema(tmpdb, acc)
     db = av.get_validated_dbname(value=tmpdb, acc=tmpacc)
     f = open(
         os.path.join(
             SubdetectorFactory.getDirectory(dbName=db,
                                             basedir=self.iovTablePath,
                                             default=True),
             self.tag_table_name), 'r')
     data = f.read()
     f.close()
     return data
コード例 #9
0
    def get_histo(self, dbName='', acc='',tag='', since=''):
        self.check_dbName_acc(dbName, acc, since);
        '''Returns histo. 
        All arguments in get_histo method have default value equal to '' just
        for avoiding exception if some parameter is missing.

        For testing:
        http://HOSTNAME:PORT/get_histo?dbName=oracle://cms_orcoff_prod/CMS_COND_31X_ECAL&tag=EcalIntercalibConstants_EBg50_EEnoB&since=1
        '''
        
        try:
            tmpdb = self.masker.unmask_dbname(dbName)
            db = av.get_validated_dbname(value = tmpdb, acc = self.masker.unmask_schema(tmpdb, acc))
            vtag = av.get_validated_tag(dbName = db, value = tag)
            vsince = av.get_validated_since(value = since.strip(), db = db, tag = vtag, onlyone = True)
            directory = self.__histodir
            histo = SubdetectorFactory.getHistoInstance(dbName = db, tag = vtag, 
                                                    since = vsince, fileType = 'png', directory = directory)
            histoData = histo.get()
        except:
            return 'Tag doesn\'t exist'
        else:
            cherrypy.response.headers['Content-Type'] = 'image/png'
            return histoData
コード例 #10
0
 def get_plot_cmp(self,
                  dbName1='',
                  acc1='',
                  tag1='',
                  since1='1',
                  fileType1='png',
                  png1='',
                  dbName2='',
                  acc2='',
                  tag2='',
                  since2='1',
                  fileType2='png',
                  png2='',
                  type='3',
                  istkmap='1'):
     self.check_dbName_acc(dbName1, acc1, since1)
     self.check_dbName_acc(dbName2, acc2, since2)
     if fileType1 != "png" and fileType2 != "png":
         cherrypy.HTTPError(405, "Bad file type !!!!!")
     tmpdb = self.masker.unmask_dbname(dbName1)
     db = av.get_validated_dbname(value=tmpdb,
                                  acc=self.masker.unmask_schema(
                                      tmpdb, acc1))
     vtag = av.get_validated_tag(dbName=db, value=tag1)
     vsince = av.get_validated_since(value=since1.strip(),
                                     db=db,
                                     tag=vtag,
                                     onlyone=True)
     plot = SubdetectorFactory.getPlotInstance(dbName=db,
                                               tag=vtag,
                                               since=vsince,
                                               fileType=fileType1,
                                               directory=self.__plotsdir,
                                               image=png1)
     img1 = plot.get(get_fname=True)
     tmpdb = self.masker.unmask_dbname(dbName2)
     db = av.get_validated_dbname(value=tmpdb,
                                  acc=self.masker.unmask_schema(
                                      tmpdb, acc2))
     vtag = av.get_validated_tag(dbName=db, value=tag2)
     vsince = av.get_validated_since(value=since2.strip(),
                                     db=db,
                                     tag=vtag,
                                     onlyone=True)
     plot = SubdetectorFactory.getPlotInstance(dbName=db,
                                               tag=vtag,
                                               since=vsince,
                                               fileType=fileType2,
                                               directory=self.__plotsdir,
                                               image=png2)
     img2 = plot.get(get_fname=True)
     #raise Exception('asdasd'+img2)
     '''if type == '1':
         img3 = ImageChops.subtract(img1, img2, scale=1, offset=128)
     elif type == '2':
         img3 = ImageChops.subtract(img2, img1, scale=1, offset=128)
     elif type == '3':
         img3 =  ImageChops.difference(img1, img2)
     elif type == '4':
         img3 = ImageChops.subtract(img1, img2, scale=1, offset=0)
     else:
         img3 = ImageChops.subtract(img2, img1, scale=1, offset=0)
     '''
     if not os.path.isdir(self.__tmpdir):
         os.makedirs(self.__tmpdir)
     temp = tempfile.TemporaryFile(dir=self.__tmpdir)
     plotTxt = ""
     if re.search('strip', vtag.lower()):
         plotTxt = 'ABSOLUTE DIFFERENCE  (The more lighter colors, the higher the difference.)'
     cmpPNG.CmpTrackerDiff(fileName1=img1,
                           fileName2=img2,
                           result=temp,
                           txt=plotTxt,
                           debug=False)
     #img3.save(temp, 'png')
     temp.seek(0)
     cherrypy.response.headers['Content-Type'] = 'image/' + fileType1
     data = temp.read()
     temp.close()
     return data