Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-26 02:34:11

0001 #!/usr/bin/env python3
0002 
0003 # For documentation of the RR XML-RPC handler, look into https://twiki.cern.ch/twiki//bin/view/CMS/DqmRrApi
0004 
0005 import sys
0006 import xmlrpclib
0007 
0008 
0009 def displayHelp():
0010   print("""
0011   getRunRegistry.py
0012 
0013   CMSSW package DQM/TrackerCommon
0014 
0015   Usage:
0016   $ getRunRegistry.py [ARGUMENTOPTION1] [ARGUMENT1] ... [OPTION2] ...
0017 
0018   Valid argument options are:
0019     -s
0020       API address of RunRegistry server
0021       default: 'http://pccmsdqm04.cern.ch/runregistry/xmlrpc'
0022     -T
0023       table identifier
0024       available: 'RUN', 'RUNLUMISECTION'
0025       default: 'RUN'
0026     -w
0027       work space identifier
0028       available: 'RPC', 'HLT', 'L1T', 'TRACKER', 'CSC', 'GLOBAL', 'ECAL'
0029       default: 'GLOBAL'
0030     -t
0031       output format type
0032       available:
0033         - table 'RUN'           : 'chart_runs_cum_evs_vs_bfield', 'chart_runs_cum_l1_124_vs_bfield', 'chart_stacked_component_status', 'csv_datasets', 'csv_run_numbers', 'csv_runs', 'tsv_datasets', 'tsv_runs', 'xml_all', 'xml_datasets'
0034         - table 'RUNLUMISECTION': 'json', 'xml'
0035       default: 'xml_all' (for table 'RUN')
0036     -f
0037       output file
0038       default: 'runRegistry.xml'
0039     -l
0040       lower bound of run numbers to consider
0041       default: '0'
0042     -u
0043       upper bound of run numbers to consider
0044       default: '1073741824'
0045 
0046   Valid options are:
0047     -h
0048       display this help and exit
0049   """)
0050 
0051 
0052 # Option handling (very simple, no validity checks)
0053 sOptions = {
0054   '-s': 'http://pccmsdqm04.cern.ch/runregistry/xmlrpc' # RunRegistry API proxy server
0055 , '-T': 'RUN'                                          # table
0056 , '-w': 'GLOBAL'                                       # workspace
0057 , '-t': 'xml_all'                                      # output format type
0058 , '-f': 'runRegistry.xml'                              # output file
0059 , '-l': '0'                                            # lower bound of run numbers to consider
0060 , '-u': '1073741824'                                   # upper bound of run numbers to consider
0061 }
0062 bOptions = {
0063   '-h': False # help option
0064 }
0065 iArgument  = 0
0066 for token in sys.argv[ 1:-1 ]:
0067   iArgument = iArgument + 1
0068   if token in sOptions.keys():
0069     if not sys.argv[ iArgument + 1 ] in sOptions.keys() and not sys.argv[ iArgument + 1 ] in bOptions.keys():
0070       del sOptions[ token ]
0071       sOptions[ token ] = sys.argv[ iArgument + 1 ]
0072 for token in sys.argv[ 1: ]:
0073   if token in bOptions.keys():
0074     del bOptions[ token ]
0075     bOptions[ token ] = True
0076 if bOptions[ '-h' ]:
0077   displayHelp()
0078   sys.exit( 0 )
0079 
0080 # Data extraction and local storage
0081 # initialise API access to defined RunRegistry proxy
0082 server = xmlrpclib.ServerProxy( sOptions[ '-s' ] )
0083 # get data according to defined table, workspace and output format type
0084 runs = '{runNumber} >= ' + sOptions[ '-l' ] + 'and {runNumber} <= ' + sOptions[ '-u' ]
0085 data = server.DataExporter.export( sOptions[ '-T' ], sOptions[ '-w' ], sOptions[ '-t' ], runs )
0086 # write data to file
0087 file = open( sOptions[ '-f' ], 'w' )
0088 file.write( data )
0089 file.close()