3 from __future__
import print_function
4 from contentValuesLib
import *
7 """ Option parser class """ 9 optparse.OptionParser.__init__(self, usage=
"%prog [options] root_file ...", version=
"%prog 0.0.1", conflict_handler=
"resolve")
10 self.add_option(
"--shift",
"-s", action=
"store", type=
"choice", dest=
"shift", choices=(
"online",
"offline"), help=
"specify shift type: online or offline values allowed. Default is offline.")
11 self.add_option(
"--url", action=
"store", type=
"string", dest=
"url", default=SERVER_URL, help=
"specify RR XML-RPC server URL. Default is " + SERVER_URL)
12 self.add_option(
"--dataset",
"-t", action=
"store", type=
"string", dest=
"dataset", default=
None, help=
"explicitly specify dataset name. If not set then script \ 13 (1) for offline shift will try to get it from the filename or (2) for online shift will set it to " + ONLINE_DATASET)
14 self.add_option(
"--debug",
"-d", action=
"store_true", dest=
"debug", default=
False, help=
"print values and exit. Do not write to RR")
15 self.add_option(
"--filter",
"-f", action=
"store", type=
"string", dest=
"filter", default=
None, help=
"Specify filters in the form \"('subsystem','folder','value')\" \ 16 in regexp expression. Default is None and this takes all the subsystems, all folders and allvalues")
18 if __name__ ==
"__main__":
22 (opts, args) = optManager.parse_args()
27 print(
"At least one ROOT file must be priovided, use --help for hit")
32 print(
"Shift type must be provided, use --help for hit")
36 default_dataset = opts[
'dataset']
37 if default_dataset ==
None and opts[
'shift'] ==
'online':
38 default_dataset = ONLINE_DATASET
45 print(
"File [", rfile,
"] not exists or is not accessible?")
51 server = xmlrpclib.ServerProxy(opts[
'url'])
57 (run_number, values) =
getSummaryValues(file_name = rfile, translate =
True, filters = filter)
59 if default_dataset ==
None:
62 dataset = default_dataset
64 if run_number ==
None:
65 print(
"Run number does not determined. Skipping file: %s" % rfile)
69 print(
"Dataset name do not determined. Skipping file: %s" % rfile)
72 if values ==
None or len(values) == 0:
73 print(
"No content summary values found. Skipping file: %s" % rfile)
78 print(
"Run number: %d" % run_number)
79 print(
"Dataset: %s" % dataset)
80 print(
"Data: ", values)
82 result = server.SummaryValuesWriter.write(run_number, dataset, json.dumps(values))
83 print(
"RR: %d rows modified for run# %d dataset %s" % (result, run_number, dataset))
84 except xmlrpclib.Error
as errstring:
85 print(
"ERROR", errstring)
def getDatasetName(file_name)
def getSummaryValues(file_name, translate, filters=None)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def checkFilter(raw_filter)