Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-07 22:33:05

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