CMS 3D CMS Logo

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