Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:11

0001 from __future__ import absolute_import
0002 from __future__ import print_function
0003 import re, json, datetime
0004 from .rrapi import RRApi, RRApiError
0005 
0006 URL  = "http://runregistry.web.cern.ch/runregistry/"
0007 
0008 def getRunsNewer(run, minLumis):
0009     try:
0010         api = RRApi(URL)
0011 
0012         if api.app == "user":
0013             result = api.data(workspace = 'GLOBAL',
0014                     table = 'runsummary',
0015                     template = 'json',
0016                     columns = [
0017                             'number',
0018                             'lsCount',
0019                             'startTime', 'duration',
0020                             'hltkey', 'gtKey', 'l1Menu', 'tscKey', 'triggerMode',
0021                             'triggers',
0022                             'runClassName',
0023                         ],
0024                     query = "{number} > %d and {lsCount} > %d and {triggers} > 0" % (run, minLumis),
0025                 )
0026             runs = {}
0027             for runDict in result :
0028                 runNo = int(runDict['number'])
0029                 runDict['date'] = datetime.datetime.strptime(runDict['startTime'], "%a %d-%m-%y %H:%M:%S").date().strftime('%Y%m%d')
0030                 runs[runNo] = runDict
0031             return runs
0032 
0033         else :
0034             print("RunRegistry API 'app' != user, who knows why... :<")
0035 
0036     except RRApiError as e:
0037         print(e)
0038 
0039 if __name__ == '__main__' :
0040     # Test run
0041     print(json.dumps(getRunsNewer(250400, 10), indent=4))