3 from contentValuesLib
import *
6 reDatasetParts =
"^/([^/]+)/([^/]+)/([^/]+)$" 7 DEFAULT_BASE =
"/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/data/" 10 (
'^/StreamExpress/',
'Express/%(numberPart1)03d/%(numberPart2)03d/DQM_V0001_R%(number)09d__StreamExpress__%(datasetPart2)s__%(datasetPart3)s.root'),
11 (
'^/Global/Online/ALL$',
'Online/%(numberPart1)03d/%(numberPart2)03d/DQM_V0003_R%(number)09d.root')
15 """ Option parser class """ 17 optparse.OptionParser.__init__(self, usage=
"%prog [options]", version=
"%prog 0.0.1", conflict_handler=
"resolve")
18 self.add_option(
"--url", action=
"store", type=
"string", dest=
"url", default=SERVER_URL, help=
"specify RR XML-RPC server URL. Default is " + SERVER_URL)
19 self.add_option(
"--from", action=
"store", type=
"int", dest=
"from", default=
None, help=
"specify run number lower threshold inclusive. Note that all runs/datasets retrieval can take a long time!")
20 self.add_option(
"--to", action=
"store", type=
"int", dest=
"to", default=
None, help=
"specify run number upper threshold inclusive. Note that all runs/datasets retrieval can take a long time!")
21 self.add_option(
"--base", action=
"store", type=
"string", dest=
"base", default=DEFAULT_BASE, help=
"file base. Default is " + DEFAULT_BASE)
26 if node.nodeType == node.TEXT_NODE:
30 if __name__ ==
"__main__":
34 (opts, args) = optManager.parse_args()
37 server = xmlrpclib.ServerProxy(opts[
'url'])
38 query = {
'hasSummaryValues':
'false'}
39 if opts[
'from'] !=
None:
40 query[
'number'] =
'>= ' +
str(opts[
'from'])
41 if opts[
'to'] !=
None:
43 query[
'number'] +=
' and <= ' +
str(opts[
'to'])
45 query[
'number'] =
'<= ' +
str(opts[
'to'])
47 xmldata = server.DataExporter.export(
'GLOBAL',
'xml_all', query)
50 dom = xml.dom.minidom.parseString(xmldata)
52 for run
in dom.getElementsByTagName(
"RUN"):
53 number =
int(
getNodeText(run.getElementsByTagName(
"NUMBER")[0].childNodes))
54 for dataset
in run.getElementsByTagName(
"DATASET"):
55 datasets.append((number,
getNodeText(dataset.getElementsByTagName(
"NAME")[0].childNodes)))
57 for (number, dataset)
in datasets:
59 m = re.search(reDatasetParts, dataset)
61 sys.stderr.write(
"Wrong dataset name (run %d, dataset %s)!\n" % (number, dataset))
63 parts = m.group(1, 2, 3)
65 for (reminderPattern, reminderFormat)
in REMINDERS:
66 if re.match(reminderPattern, dataset):
67 reminder = reminderFormat % \
68 {
'number': number,
'dataset': dataset,
69 'numberPart1':
int(re.search(
'^([0-9]+)([0-9]{3})$',
str(number)).
group(1)),
70 'numberPart2':
int(re.search(
'^([0-9]+)([0-9]{3})$',
str(number)).
group(2)),
71 'datasetPart1': parts[0],
72 'datasetPart2': parts[1],
73 'datasetPart3': parts[2]
75 fullPath = opts[
'base'] + reminder
79 sys.stderr.write(
"Dataset was not identified (run %d, dataset %s)!\n" % (number, dataset))
83 sys.stdout.write(fullPath)
84 sys.stdout.write(
'\n')
86 sys.stderr.write(
"File [%s] not exists or is not accessible (run %d, dataset %s)!\n" % (fullPath, number, dataset))
def getNodeText(nodelist)