CMS 3D CMS Logo

getRunRegistry.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # For documentation of the RR XML-RPC handler, look into https://twiki.cern.ch/twiki//bin/view/CMS/DqmRrApi
4 
5 from __future__ import print_function
6 import sys
7 import xmlrpclib
8 
9 
11  print("""
12  getRunRegistry.py
13 
14  CMSSW package DQM/TrackerCommon
15 
16  Usage:
17  $ getRunRegistry.py [ARGUMENTOPTION1] [ARGUMENT1] ... [OPTION2] ...
18 
19  Valid argument options are:
20  -s
21  API address of RunRegistry server
22  default: 'http://pccmsdqm04.cern.ch/runregistry/xmlrpc'
23  -T
24  table identifier
25  available: 'RUN', 'RUNLUMISECTION'
26  default: 'RUN'
27  -w
28  work space identifier
29  available: 'RPC', 'HLT', 'L1T', 'TRACKER', 'CSC', 'GLOBAL', 'ECAL'
30  default: 'GLOBAL'
31  -t
32  output format type
33  available:
34  - 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'
35  - table 'RUNLUMISECTION': 'json', 'xml'
36  default: 'xml_all' (for table 'RUN')
37  -f
38  output file
39  default: 'runRegistry.xml'
40  -l
41  lower bound of run numbers to consider
42  default: '0'
43  -u
44  upper bound of run numbers to consider
45  default: '1073741824'
46 
47  Valid options are:
48  -h
49  display this help and exit
50  """)
51 
52 
53 # Option handling (very simple, no validity checks)
54 sOptions = {
55  '-s': 'http://pccmsdqm04.cern.ch/runregistry/xmlrpc' # RunRegistry API proxy server
56 , '-T': 'RUN' # table
57 , '-w': 'GLOBAL' # workspace
58 , '-t': 'xml_all' # output format type
59 , '-f': 'runRegistry.xml' # output file
60 , '-l': '0' # lower bound of run numbers to consider
61 , '-u': '1073741824' # upper bound of run numbers to consider
62 }
63 bOptions = {
64  '-h': False # help option
65 }
66 iArgument = 0
67 for token in sys.argv[ 1:-1 ]:
68  iArgument = iArgument + 1
69  if token in sOptions.keys():
70  if not sys.argv[ iArgument + 1 ] in sOptions.keys() and not sys.argv[ iArgument + 1 ] in bOptions.keys():
71  del sOptions[ token ]
72  sOptions[ token ] = sys.argv[ iArgument + 1 ]
73 for token in sys.argv[ 1: ]:
74  if token in bOptions.keys():
75  del bOptions[ token ]
76  bOptions[ token ] = True
77 if bOptions[ '-h' ]:
78  displayHelp()
79  sys.exit( 0 )
80 
81 # Data extraction and local storage
82 # initialise API access to defined RunRegistry proxy
83 server = xmlrpclib.ServerProxy( sOptions[ '-s' ] )
84 # get data according to defined table, workspace and output format type
85 runs = '{runNumber} >= ' + sOptions[ '-l' ] + 'and {runNumber} <= ' + sOptions[ '-u' ]
86 data = server.DataExporter.export( sOptions[ '-T' ], sOptions[ '-w' ], sOptions[ '-t' ], runs )
87 # write data to file
88 file = open( sOptions[ '-f' ], 'w' )
89 file.write( data )
90 file.close()
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65