Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Qipeng Hu
athena
Commits
ec235493
Commit
ec235493
authored
Feb 01, 2020
by
Adam Edward Barton
Browse files
Merge branch 'py3.TrigValTools-20200131' into 'master'
TrigValTools: python 3 fixes See merge request
atlas/athena!29994
parents
b7f5218b
949d4653
Changes
6
Hide whitespace changes
Inline
Side-by-side
Trigger/TrigValidation/TrigValTools/bin/chainDump.py
View file @
ec235493
#!/usr/bin/env python
#
# Copyright (C) 2002-20
19
CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-20
20
CERN for the benefit of the ATLAS collaboration
#
'''Script to dump trigger counts to a text file'''
...
...
@@ -308,9 +308,10 @@ def main():
if
len
(
in_total_hists
)
==
0
:
logging
.
error
(
'No total-events histogram could be loaded'
)
return
1
in_total
=
in_total_hists
.
values
()[
0
].
GetEntries
()
items
=
list
(
in_total_hists
.
items
())
in_total
=
items
[
0
][
1
].
GetEntries
()
logging
.
info
(
'Loaded total-events histogram %s, number of events: %d'
,
i
n_total_hists
.
keys
()
[
0
],
in_total
)
i
tems
[
0
]
[
0
],
in_total
)
ref_hists
=
None
ref_total_hists
=
None
...
...
@@ -336,7 +337,7 @@ def main():
json_dict
=
OrderedDict
()
json_dict
[
total_events_key
]
=
OrderedDict
()
json_dict
[
total_events_key
][
'hist_name'
]
=
in_total_hists
.
keys
()[
0
]
json_dict
[
total_events_key
][
'hist_name'
]
=
list
(
in_total_hists
.
keys
()
)
[
0
]
json_dict
[
total_events_key
][
'count'
]
=
int
(
in_total
)
json_dict
[
total_events_key
][
'ref_count'
]
=
int
(
ref_total
)
if
ref_total
else
'n/a'
...
...
Trigger/TrigValidation/TrigValTools/bin/check_log.py
View file @
ec235493
#!/usr/bin/env python
# Copyright (C) 2002-20
19
CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-20
20
CERN for the benefit of the ATLAS collaboration
import
re
import
argparse
import
sys
import
os
import
six
desc
=
'Tool to check for error messages in a log file. By default ERROR, FATAL
\
and CRITICAL messages are considered. The config file may be used to
\
...
...
@@ -130,7 +131,8 @@ def scanLogfile():
msgLevels
=
re
.
compile
(
'|'
.
join
(
pattern
))
igLevels
=
re
.
compile
(
'|'
.
join
(
ignorePattern
))
logFileAddress
=
args
.
logfile
with
open
(
logFileAddress
,
'r'
)
as
logFile
:
encargs
=
{}
if
six
.
PY2
else
{
'encoding'
:
'utf-8'
}
with
open
(
logFileAddress
,
'r'
,
**
encargs
)
as
logFile
:
tracing
=
False
for
line
in
logFile
:
#Tracing only makes sense for errors
...
...
Trigger/TrigValidation/TrigValTools/bin/messageCounter.py
View file @
ec235493
#!/usr/bin/env python
#
# Copyright (C) 2002-20
19
CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-20
20
CERN for the benefit of the ATLAS collaboration
#
'''
...
...
@@ -16,6 +16,7 @@ import logging
import
argparse
import
json
from
collections
import
OrderedDict
import
six
default_ignore_patterns
=
[
...
...
@@ -42,7 +43,7 @@ def get_parser():
action
=
'append'
,
default
=
[],
help
=
'Add an ignore pattern to the default ones.'
+
'The option can be specified multiple times. Defaults are: {:s}'
.
format
(
default_ignore_patterns
))
'The option can be specified multiple times. Defaults are: {:s}'
.
format
(
str
(
default_ignore_patterns
))
)
parser
.
add_argument
(
'-p'
,
'--printMessages'
,
action
=
'store_true'
,
help
=
'Print the messages found in analysed files'
)
...
...
@@ -100,11 +101,11 @@ def make_summary(result):
def
print_result
(
summary
,
full_result
,
print_messages
=
False
):
summary_str
=
'Found the following number of messages:
\n
'
for
p
,
n
in
s
ummary
.
iteritems
():
for
p
,
n
in
s
ix
.
iteritems
(
summary
):
summary_str
+=
'{:8d} {:s} messages
\n
'
.
format
(
n
,
p
)
logging
.
info
(
summary_str
)
if
print_messages
:
for
p
,
lines
in
full_result
.
iteritems
(
):
for
p
,
lines
in
six
.
iteritems
(
full_result
):
logging
.
info
(
'##### The following %s messages were found #####'
,
p
)
for
line
in
lines
:
print
(
line
,
end
=
''
)
# noqa: ATL901
...
...
@@ -132,7 +133,8 @@ def main():
logging
.
error
(
'Cannot open file %s, skipping'
,
fname
)
continue
logging
.
info
(
'Analysing file %s'
,
fname
)
with
open
(
fname
)
as
f
:
encargs
=
{}
if
six
.
PY2
else
{
'encoding'
:
'utf-8'
}
with
open
(
fname
,
**
encargs
)
as
f
:
messages
=
extract_messages
(
f
,
start
,
end
,
ignore
)
summary
=
make_summary
(
messages
)
print_result
(
summary
,
messages
,
args
.
printMessages
)
...
...
Trigger/TrigValidation/TrigValTools/bin/trig-test-json.py
View file @
ec235493
#!/usr/bin/env python
#
# Copyright (C) 2002-20
19
CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-20
20
CERN for the benefit of the ATLAS collaboration
#
# This script parses outputs of trigger nightly test post-processing steps
...
...
@@ -13,6 +13,7 @@ import sys
import
logging
import
os.path
from
collections
import
OrderedDict
import
six
class
LastUpdatedOrderedDict
(
OrderedDict
):
...
...
@@ -63,7 +64,7 @@ def convert_to_megabytes(number, unit):
"GB"
:
1024
,
'TB'
:
1024
**
2
}
for
unit_name
,
mult
in
multipliers
.
iteritems
(
):
for
unit_name
,
mult
in
six
.
iteritems
(
multipliers
):
if
unit_name
==
unit
:
return
float
(
number
)
*
mult
logging
.
error
(
"Unit conversion failed from {} to MB"
.
format
(
unit
))
...
...
Trigger/TrigValidation/TrigValTools/python/TrigValSteering/CheckSteps.py
View file @
ec235493
#
# Copyright (C) 2002-20
19
CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-20
20
CERN for the benefit of the ATLAS collaboration
#
'''
...
...
@@ -11,6 +11,7 @@ import os
import
re
import
subprocess
import
json
import
six
from
TrigValTools.TrigValSteering.Step
import
Step
from
TrigValTools.TrigValSteering.Common
import
art_input_eos
,
art_input_cvmfs
...
...
@@ -127,8 +128,9 @@ class LogMergeStep(Step):
self
.
log_files
.
append
(
f
)
def
merge_logs
(
self
):
encargs
=
{}
if
six
.
PY2
else
{
'encoding'
:
'utf-8'
}
try
:
with
open
(
self
.
merged_name
,
'w'
)
as
merged_file
:
with
open
(
self
.
merged_name
,
'w'
,
**
encargs
)
as
merged_file
:
for
log_name
in
self
.
log_files
:
if
not
os
.
path
.
isfile
(
log_name
):
if
self
.
warn_if_missing
:
...
...
@@ -136,7 +138,7 @@ class LogMergeStep(Step):
merged_file
.
write
(
'### WARNING Missing {} ###
\n
'
.
format
(
log_name
))
continue
with
open
(
log_name
)
as
log_file
:
with
open
(
log_name
,
**
encargs
)
as
log_file
:
merged_file
.
write
(
'### {} ###
\n
'
.
format
(
log_name
))
for
line
in
log_file
:
merged_file
.
write
(
line
)
...
...
@@ -266,10 +268,11 @@ class RegTestStep(RefComparisonStep):
if
not
os
.
path
.
isfile
(
log_file
):
self
.
log
.
error
(
'%s input file %s is missing'
,
self
.
name
,
log_file
)
return
False
with
open
(
log_file
)
as
f_in
:
encargs
=
{}
if
six
.
PY2
else
{
'encoding'
:
'utf-8'
}
with
open
(
log_file
,
**
encargs
)
as
f_in
:
matches
=
re
.
findall
(
'{}.*$'
.
format
(
self
.
regex
),
f_in
.
read
(),
re
.
MULTILINE
)
with
open
(
self
.
input_file
,
'w'
)
as
f_out
:
with
open
(
self
.
input_file
,
'w'
,
**
encargs
)
as
f_out
:
for
line
in
matches
:
f_out
.
write
(
line
+
'
\n
'
)
return
True
...
...
@@ -495,7 +498,8 @@ class ZeroCountsStep(Step):
self
.
name
,
input_file
)
return
-
1
lines_checked
=
0
with
open
(
input_file
)
as
f_in
:
encargs
=
{}
if
six
.
PY2
else
{
'encoding'
:
'utf-8'
}
with
open
(
input_file
,
**
encargs
)
as
f_in
:
for
line
in
f_in
.
readlines
():
split_line
=
line
.
split
()
lines_checked
+=
1
...
...
Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py
View file @
ec235493
#
# Copyright (C) 2002-20
19
CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-20
20
CERN for the benefit of the ATLAS collaboration
#
'''
...
...
@@ -118,7 +118,7 @@ class Test(object):
if
exit_code
==
0
:
exit_msg
+=
' because all required steps were successful'
else
:
exit_msg
+=
' because the following required steps failed: {:s}'
.
format
(
failed_required_steps
)
exit_msg
+=
' because the following required steps failed: {:s}'
.
format
(
str
(
failed_required_steps
)
)
self
.
log
.
info
(
exit_msg
)
return
exit_code
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment