CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
lumiData2.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 VERSION='2.00'
3 import os,sys
4 import coral
5 from RecoLuminosity.LumiDB import argparse,lumiCalcAPI,sessionManager
6 
7 def listRemoveDuplicate(inlist):
8  d={}
9  for x in inlist:
10  d[x]=x
11  return d.values()
12 
13 def main():
14  parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="list lumi data availability")
15  # add required arguments
16  parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB')
17  # add optional arguments
18  parser.add_argument('-P',dest='authpath',action='store',help='path to authentication file')
19  parser.add_argument('-siteconfpath',dest='siteconfpath',action='store',
20  default=None,
21  required=False,
22  help='specific path to site-local-config.xml file, optional. If path undefined, fallback to cern proxy&server')
23  parser.add_argument('action',choices=['listrun'],help='command actions')
24  parser.add_argument('--minrun',
25  dest='minrun',
26  action='store',
27  type=int,
28  help='min run number')
29  parser.add_argument('--maxrun',
30  dest='maxrun',
31  action='store',
32  type=int,
33  help='max run number')
34  parser.add_argument('--minfill',
35  dest='minfill',
36  type=int,
37  action='store',
38  help='min fill number')
39  parser.add_argument('--maxfill',
40  dest='maxfill',
41  type=int,
42  action='store',
43  help='max fill number')
44  parser.add_argument('--verbose',
45  dest='verbose',
46  action='store_true',
47  help='verbose mode for printing' )
48  parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
49  # parse arguments
50  options=parser.parse_args()
51  if options.authpath:
52  os.environ['CORAL_AUTH_PATH'] = options.authpath
53  svc=sessionManager.sessionManager(options.connect,authpath=options.authpath,debugON=options.debug)
54  session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
55  reqTrg=True
56  reqHLT=False
57  session.transaction().start(True)
58  schema=session.nominalSchema()
59  runlist=lumiCalcAPI.runList(schema,None,runmin=options.minrun,runmax=options.maxrun,startT=None,stopT=None,l1keyPattern=None,hltkeyPattern=None,amodetag=None,nominalEnergy=None,energyFlut=None,requiretrg=reqTrg,requirehlt=reqHLT)
60  session.transaction().commit()
61  if options.action == 'listrun':
62  if not runlist:
63  print '[]'
64  sys.exit(0)
65  singlelist=listRemoveDuplicate(runlist)
66  singlelist.sort()
67  print singlelist
68  del session
69  del svc
70 if __name__=='__main__':
71  main()
72 
Definition: start.py:1
def main
Definition: lumiData2.py:13
Definition: main.py:1
def listRemoveDuplicate
Definition: lumiData2.py:7