CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
rrClient.py
Go to the documentation of this file.
1 import re, json, datetime
2 from rrapi import RRApi, RRApiError
3 
4 URL = "http://runregistry.web.cern.ch/runregistry/"
5 
6 def getRunsNewer(run, minLumis):
7  try:
8  api = RRApi(URL)
9 
10  if api.app == "user":
11  result = api.data(workspace = 'GLOBAL',
12  table = 'runsummary',
13  template = 'json',
14  columns = [
15  'number',
16  'lsCount',
17  'startTime', 'duration',
18  'hltkey', 'gtKey', 'l1Menu', 'tscKey', 'triggerMode',
19  'triggers',
20  'runClassName',
21  ],
22  query = "{number} > %d and {lsCount} > %d and {triggers} > 0" % (run, minLumis),
23  )
24  runs = {}
25  for runDict in result :
26  runNo = int(runDict['number'])
27  runDict['date'] = datetime.datetime.strptime(runDict['startTime'], "%a %d-%m-%y %H:%M:%S").date().strftime('%Y%m%d')
28  runs[runNo] = runDict
29  return runs
30 
31  else :
32  print "RunRegistry API 'app' != user, who knows why... :<"
33 
34  except RRApiError, e:
35  print e
36 
37 if __name__ == '__main__' :
38  # Test run
39  print json.dumps(getRunsNewer(250400, 10), indent=4)
def getRunsNewer
Definition: rrClient.py:6