CMS 3D CMS Logo

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