00001
00002 VERSION='2.00'
00003 import os,sys
00004 import coral
00005 from RecoLuminosity.LumiDB import argparse,lumiCalcAPI,sessionManager
00006
00007 def listRemoveDuplicate(inlist):
00008 d={}
00009 for x in inlist:
00010 d[x]=x
00011 return d.values()
00012
00013 def main():
00014 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="list lumi data availability")
00015
00016 parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB')
00017
00018 parser.add_argument('-P',dest='authpath',action='store',help='path to authentication file')
00019 parser.add_argument('-siteconfpath',dest='siteconfpath',action='store',
00020 default=None,
00021 required=False,
00022 help='specific path to site-local-config.xml file, optional. If path undefined, fallback to cern proxy&server')
00023 parser.add_argument('action',choices=['listrun'],help='command actions')
00024 parser.add_argument('--minrun',
00025 dest='minrun',
00026 action='store',
00027 type=int,
00028 help='min run number')
00029 parser.add_argument('--maxrun',
00030 dest='maxrun',
00031 action='store',
00032 type=int,
00033 help='max run number')
00034 parser.add_argument('--minfill',
00035 dest='minfill',
00036 type=int,
00037 action='store',
00038 help='min fill number')
00039 parser.add_argument('--maxfill',
00040 dest='maxfill',
00041 type=int,
00042 action='store',
00043 help='max fill number')
00044 parser.add_argument('--verbose',
00045 dest='verbose',
00046 action='store_true',
00047 help='verbose mode for printing' )
00048 parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
00049
00050 options=parser.parse_args()
00051 if options.authpath:
00052 os.environ['CORAL_AUTH_PATH'] = options.authpath
00053 svc=sessionManager.sessionManager(options.connect,authpath=options.authpath,debugON=options.debug)
00054 session=svc.openSession(isReadOnly=True,cpp2sqltype=[('unsigned int','NUMBER(10)'),('unsigned long long','NUMBER(20)')])
00055 reqTrg=True
00056 reqHLT=False
00057 session.transaction().start(True)
00058 schema=session.nominalSchema()
00059 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)
00060 session.transaction().commit()
00061 if options.action == 'listrun':
00062 if not runlist:
00063 print '[]'
00064 sys.exit(0)
00065 singlelist=listRemoveDuplicate(runlist)
00066 singlelist.sort()
00067 print singlelist
00068 del session
00069 del svc
00070 if __name__=='__main__':
00071 main()
00072