CMS 3D CMS Logo

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