CMS 3D CMS Logo

Functions | Variables

lumiData Namespace Reference

Functions

def defaultfrontierConfigString
def listRemoveDuplicate
def main
def printRunList
def runListInDB

Variables

string VERSION = '2.00'

Function Documentation

def lumiData::defaultfrontierConfigString (   self)

Definition at line 7 of file lumiData.py.

00008                                      :
        return """<frontier-connect><proxy url="https://cmst0frontier.cern.ch:3128"/><proxy url="https://cmst0frontier.cern.ch:3128"/><proxy url="https://cmst0frontier1.cern.ch:3128"/><proxy url="https://cmst0frontier2.cern.ch:3128"/><server url="https://cmsfrontier.cern.ch:8000/FrontierInt"/><server url="https://cmsfrontier.cern.ch:8000/FrontierInt"/><server url="https://cmsfrontier1.cern.ch:8000/FrontierInt"/><server url="https://cmsfrontier2.cern.ch:8000/FrontierInt"/><server url="https://cmsfrontier3.cern.ch:8000/FrontierInt"/><server url="https://cmsfrontier4.cern.ch:8000/FrontierInt"/></frontier-connect>"""
def lumiData::listRemoveDuplicate (   inlist)

Definition at line 9 of file lumiData.py.

00010                                :
00011     d={}
00012     for x in inlist:
00013         d[x]=x
00014     return d.values()

def lumiData::main ( )

Definition at line 60 of file lumiData.py.

00061           :
00062     parser = argparse.ArgumentParser(prog=os.path.basename(sys.argv[0]),description="Lumi Data operations")
00063     # add required arguments
00064     parser.add_argument('-c',dest='connect',action='store',required=True,help='connect string to lumiDB')
00065     # add optional arguments
00066     parser.add_argument('-P',dest='authpath',action='store',help='path to authentication file')
00067     parser.add_argument('-lumiversion',dest='lumiversion',action='store',help='lumi data version, optional')
00068     parser.add_argument('-siteconfpath',dest='siteconfpath',action='store',help='specific path to site-local-config.xml file, default to $CMS_PATH/SITECONF/local/JobConfig, if path undefined, fallback to cern proxy&server')
00069     parser.add_argument('action',choices=['listrun'],help='command actions')
00070     parser.add_argument('--raw',dest='printraw',action='store_true',help='print raw data' )
00071     parser.add_argument('--verbose',dest='verbose',action='store_true',help='verbose mode for printing' )
00072     parser.add_argument('--debug',dest='debug',action='store_true',help='debug')
00073     # parse arguments
00074     args=parser.parse_args()
00075     connectstring=args.connect
00076     connectparser=connectstrParser.connectstrParser(connectstring)
00077     connectparser.parse()
00078     usedefaultfrontierconfig=False
00079     cacheconfigpath=''
00080     if connectparser.needsitelocalinfo():
00081         if not args.siteconfpath:
00082             cacheconfigpath=os.environ['CMS_PATH']
00083             if cacheconfigpath:
00084                 cacheconfigpath=os.path.join(cacheconfigpath,'SITECONF','local','JobConfig','site-local-config.xml')
00085             else:
00086                 usedefaultfrontierconfig=True
00087         else:
00088             cacheconfigpath=args.siteconfpath
00089             cacheconfigpath=os.path.join(cacheconfigpath,'site-local-config.xml')
00090         p=cacheconfigParser.cacheconfigParser()
00091         if usedefaultfrontierconfig:
00092             p.parseString(c.defaultfrontierConfigString)
00093         else:
00094             p.parse(cacheconfigpath)
00095         connectstring=connectparser.fullfrontierStr(connectparser.schemaname(),p.parameterdict())
00096     #print 'connectstring',connectstring
00097     runnumber=0
00098     svc = coral.ConnectionService()
00099     isverbose=False
00100     if args.debug :
00101         msg=coral.MessageStream('')
00102         msg.setMsgVerbosity(coral.message_Level_Debug)
00103         c.VERBOSE=True
00104 
00105     if args.verbose :
00106         c.VERBOSE=True
00107     if args.authpath and len(args.authpath)!=0:
00108         os.environ['CORAL_AUTH_PATH']=args.authpath
00109 
00110     session=svc.connect(connectstring,accessMode=coral.access_Update)
00111     session.typeConverter().setCppTypeForSqlType("unsigned int","NUMBER(10)")
00112 
00113     if args.action == 'listrun':
00114         lumiversion=''
00115         if args.lumiversion:
00116             lumiversion=args.lumiversion
00117         runlist=runListInDB(session,lumiversion)
00118         if args.printraw:
00119             print runlist
00120         else: printRunList(runlist)
00121     
00122     del session
    del svc
def lumiData::printRunList (   runlistdata)

Definition at line 53 of file lumiData.py.

00054                              :
00055     result=[['Run','Lumiversion']]
00056     for tp in runlistdata:
00057         i=[str(tp[0]),tp[1]]
00058         result.append(i)
00059     print tablePrinter.indent(result,hasHeader=True,separateRows=False,prefix='| ',postfix=' |',wrapfunc=lambda x: wrap_onspace(x,20) )
    
def lumiData::runListInDB (   dbsession,
  lumiversion = '' 
)
list available runs in the DB
output: [runnumber]

Definition at line 15 of file lumiData.py.

00016                                          :
00017     """
00018     list available runs in the DB
00019     output: [runnumber]
00020     """ 
00021     runlist=[]
00022     try:
00023         dbsession.transaction().start(True)
00024         schema=dbsession.nominalSchema()
00025          
00026         query=schema.tableHandle(nameDealer.lumisummaryTableName()).newQuery()
00027         query.addToOutputList("RUNNUM","run")
00028         query.addToOutputList("LUMIVERSION","lumiversion")
00029         queryBind=coral.AttributeList()
00030         queryBind.extend("lumiversion","string")
00031         if len(lumiversion)!=0:
00032             queryBind["lumiversion"].setData(lumiversion)
00033             query.setCondition("LUMIVERSION=:lumiversion",queryBind)
00034         query.addToOrderList('RUNNUM')
00035         result=coral.AttributeList()
00036         result.extend("run","unsigned int")
00037         result.extend("lumiversion","string")
00038         query.defineOutput(result)
00039         cursor=query.execute()
00040         while cursor.next():
00041             r=cursor.currentRow()['run'].data()
00042             v=cursor.currentRow()['lumiversion'].data()
00043             runlist.append((r,v))
00044         del query
00045         dbsession.transaction().commit()
00046     except Exception,e:
00047         print str(e)
00048         dbsession.transaction().rollback()
00049         del dbsession
00050     runlist=listRemoveDuplicate(runlist)
00051     runlist.sort()
00052     return runlist


Variable Documentation

string lumiData::VERSION = '2.00'

Definition at line 2 of file lumiData.py.