def get_json_data(self,
                      site='T%',
                      source='',
                      timestart=datetime.now(),
                      timestop=(datetime.now() - timedelta(days=30))):

        self.validateSiteName(site)

        if not Lexicon.accsource(source):
            raise popularityInterfaceException(
                "Given source (access data source) is not valid")

        par = victorinterfaceparams()
        try:
            par.setSiteName(site)
            logger.info('debug. siteName = %s' % par.SiteName)

            if source == '':
                if par.SiteName == 'T2_CH_CERN' or par.SiteName == 'T0_CH_CERN':
                    source = 'xrootd'
                    par.SiteName = 'T2_CH_CERN'
                else:
                    source = 'crab'
            par.setSource(source)

            if self.lastAcc:
                pop_data = victorinterfaceDB.WhatInSiteWithStatLastAcc(
                    collType='BlocksStat', params=par)
            else:
                par.setTStart(timestart)
                par.setTStop(timestop)
                pop_data = victorinterfaceDB.WhatInSiteWithStat(
                    collType='BlocksStat', params=par)
        except Paramvalidationexception as e:
            raise popularityInterfaceException(e.getmessage())
        except victorinterfaceDB.PopularityDBException as dbe:
            raise popularityInterfaceException(dbe.getmessage())
        except Exception as ex:
            raise popularityInterfaceException(ex)

        try:
            pop_data[site]
        except KeyError:
            logger.warning('WARNING: empty popularity results for %s' % site)
        return pop_data
Beispiel #2
0
    def get_json_data(self, site, source, timestart=None, timestop=None):
        self.validateSiteName(site)
            
        params  = {'sitename':site, 'tstart': timestart, 'tstop': timestop}
        if not timestart and not timestop:
            params  = {'sitename':site}
   
        if Lexicon.accsource(source):
            params['source'] = source
        else:
            raise popularityInterfaceException("Given source (access data source) is not valid")

        pop_data = httpInterface.get_json_data(self, params)
        try:
            pop_data[site]
        except KeyError:
            logger.warning('WARNING: empty popularity results for %s' % site)
        return pop_data
Beispiel #3
0
    def get_json_data(self, site='T%', source='', timestart=datetime.now(), timestop=(datetime.now() - timedelta(days=30))):
        
        self.validateSiteName(site)
            
        if not Lexicon.accsource(source):
            raise popularityInterfaceException("Given source (access data source) is not valid")

        par = victorinterfaceparams()
        try:
            par.setSiteName(site)
            logger.info('debug. siteName = %s' % par.SiteName)
    
            if source=='':
                if par.SiteName == 'T2_CH_CERN' or par.SiteName == 'T0_CH_CERN':
                    source = 'xrootd'
                    par.SiteName = 'T2_CH_CERN'
                else:
                    source = 'crab'
            par.setSource(source)

            
            if self.lastAcc:
                pop_data = victorinterfaceDB.WhatInSiteWithStatLastAcc(collType='BlocksStat', params=par)
            else:
                par.setTStart(timestart)
                par.setTStop(timestop)
                pop_data = victorinterfaceDB.WhatInSiteWithStat(collType='BlocksStat', params=par)
        except Paramvalidationexception as e:
            raise popularityInterfaceException(e.getmessage())
        except victorinterfaceDB.PopularityDBException as dbe:
            raise popularityInterfaceException(dbe.getmessage())
        except Exception as ex:
            raise popularityInterfaceException(ex)

        try:
            pop_data[site]
        except KeyError:
            logger.warning('WARNING: empty popularity results for %s' % site)
        return pop_data
Beispiel #4
0
 def validateSource(self, source):
     if lexicon.accsource(source):
          return True
     raise Paramvalidationexception('source', 'param must be a valid source name')