00061 :
00062 parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="apply normalization factor to inst lumi")
00063 parser.add_argument('-c',dest='connectstr',action='store',required=True,help='connectstr')
00064 parser.add_argument('-norm',dest='normfactor',action='store',required=True,help='normalization factor to apply')
00065 parser.add_argument('-P',dest='authpath',action='store',required=True,help='path to authentication file')
00066 parser.add_argument('-r',dest='runnumber',action='store',required=False,help='run number')
00067 parser.add_argument('-startrun',dest='startrun',action='store',required=False,help='start run for range action')
00068 parser.add_argument('-endrun',dest='endrun',action='store',required=False,help='end run for range action')
00069 parser.add_argument('action',choices=['run','range'],help='calibrate run')
00070
00071 parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
00072 args=parser.parse_args()
00073 connectstr=args.connectstr
00074 normfactor=args.normfactor
00075 if len(args.authpath)!=0:
00076 os.environ['CORAL_AUTH_PATH']=args.authpath
00077 else:
00078 raise '-P authpath argument is required'
00079 svc=coral.ConnectionService()
00080 session=svc.connect(connectstr,accessMode=coral.access_Update)
00081 if args.debug:
00082 msg=coral.MessageStream('')
00083 msg.setMsgVerbosity(coral.message_Level_Debug)
00084 n=0
00085 if args.action == 'run':
00086 runnumber=0
00087 if args.runnumber:
00088 runnumber=args.runnumber
00089 else:
00090 raise 'argument -r is required for action run'
00091 if args.debug:
00092 print 'connectstr : ',connectstr
00093 print 'normfactor : ',normfactor
00094 print 'authpath : ',os.environ['CORAL_AUTH_PATH']
00095 print 'runnumber : ',runnumber
00096 n=calibrateRun(session,normfactor,runnumber)
00097 if args.action == 'range':
00098 startrun=0
00099 endrun=0
00100 if args.startrun:
00101 startrun=args.startrun
00102 else:
00103 raise 'argument -startrun is required for action range'
00104 if args.endrun:
00105 endrun=args.endrun
00106 else:
00107 raise 'argument -endrun is required for action range'
00108 if args.debug:
00109 print 'connectstr : ',connectstr
00110 print 'normfactor : ',normfactor
00111 print 'authpath : ',os.environ['CORAL_AUTH_PATH']
00112 print 'startrun : ',startrun
00113 print 'endrun : ',endrun
00114 n=calibrateRange(session,normfactor,startrun,endrun)
00115 print 'number of rows changed: ',n
00116 del session
00117 del svc