Main Page
Namespaces
Classes
Package Documentation
DQM
Integration
scripts
contentValuesCheck.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
from
__future__
import
print_function
4
from
contentValuesLib
import
*
5
6
class
OptionParser
(optparse.OptionParser):
7
""" Option parser class """
8
def
__init__
(self):
9
optparse.OptionParser.__init__(self, usage=
"%prog [options] root_file ..."
, version=
"%prog 0.0.1"
, conflict_handler=
"resolve"
)
10
self.add_option(
"--silent"
,
"-s"
, action=
"store_true"
, dest=
"silent"
, default=
False
, help=
"silent mode: specify return code and exit"
)
11
self.add_option(
"--subsystem"
,
"-c"
, action=
"store"
, type=
"string"
, dest=
"subsystem"
, default=
None
, help=
"Specify test subsystem"
)
12
13
if
__name__ ==
"__main__"
:
14
15
# Create option parser and get options/arguments
16
optManager =
OptionParser
()
17
(opts, args) = optManager.parse_args()
18
opts = opts.__dict__
19
20
# Check if at least one root file defined (can be many!)
21
if
len(args) == 0:
22
print
(
"At least one ROOT file must be priovided, use --help for hit"
)
23
sys.exit(1)
24
25
# Check if all files exists and are accessible
26
for
rfile
in
args:
27
try
:
28
os.stat(rfile)
29
except
:
30
print
(
"File ["
, rfile,
"] not exists or is not accessible?"
)
31
sys.exit(2)
32
33
ss = opts[
'subsystem'
]
34
35
# Lets extract values from files one-by-one, construct hashmap and check values
36
for
rfile
in
args:
37
38
(run_number, values) =
getSummaryValues
(file_name = rfile, shift_type =
None
, translate =
False
, filters =
None
)
39
40
if
values ==
None
or
len(values) == 0:
41
print
(
"No content summary values found. Skipping file: %s"
% rfile)
42
continue
43
44
messages = []
45
for
sub
in
SUBSYSTEMS.keys():
46
47
if
not
ss ==
None
and
not
sub == ss:
48
continue
49
50
if
sub
not
in
values:
51
messages.append(
"%s: missing subsystem!"
% sub)
52
continue
53
54
skeys = {}
55
sfolders = []
56
57
for
folder
in
FOLDERS.keys():
58
59
if
folder
not
in
values[sub]:
60
messages.append(
"%s: missing folder EventInfo/%s"
% (sub, folder))
61
continue
62
63
if
len(values[sub][folder]) == 0:
64
messages.append(
"%s: empty folder EventInfo/%s"
% (sub, FOLDERS[folder][1]))
65
continue
66
67
sfolders.append(folder)
68
69
if
'Summary'
not
in
values[sub][folder]:
70
messages.append(
"%s: missing summary value EventInfo/%s"
% (sub, FOLDERS[folder][1]))
71
72
for
key
in
values[sub][folder].
keys
():
73
if
key ==
'Summary'
:
74
continue
75
if
key
not
in
skeys:
76
skeys[key] = []
77
skeys[key].
append
(folder)
78
79
for
key
in
skeys:
80
nfound = []
81
for
folder
in
sfolders:
82
if
skeys[key].
count
(folder) == 0: nfound.append(folder)
83
if
len(nfound) > 0:
84
messages.append(
"%s: value (%s)/%s not found in (%s)"
% (sub,
','
.
join
(skeys[key]), key,
','
.
join
(nfound)))
85
86
if
not
opts[
'silent'
]:
87
for
message
in
sorted(messages):
print
(message)
88
print
(
"%d errors found"
% len(messages))
89
90
if
len(messages) > 0: sys.exit(1)
91
92
sys.exit(0)
93
94
KineDebug3::count
void count()
Definition:
KinematicConstrainedVertexUpdatorT.h:23
contentValuesCheck.OptionParser.__init__
def __init__(self)
Definition:
contentValuesCheck.py:8
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition:
JobReport.cc:66
contentValuesLib.getSummaryValues
def getSummaryValues(file_name, translate, filters=None)
Definition:
contentValuesLib.py:41
relativeConstraints.keys
keys
Definition:
relativeConstraints.py:89
mps_setup.append
append
Definition:
mps_setup.py:84
join
static std::string join(char **cmd)
Definition:
RemoteFile.cc:18
contentValuesCheck.OptionParser
Definition:
contentValuesCheck.py:6
Generated for CMSSW Reference Manual by
1.8.11