Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-27 03:17:45

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