14 from collections
import OrderedDict
15 from enum
import IntEnum
19 'Store items in the order the keys were last added'
24 OrderedDict.__setitem__(self, key, value)
28 'Defines columns in hitstats file'
31 TOTAL_HITS_PER_EVT = 2
32 TOTAL_ROB_FRAC_PER_EVT = 3
33 TOTAL_BYTES_PER_EVT = 4
34 NOBLD_HITS_PER_EVT = 5
35 NOBLD_ROB_FRAC_PER_EVT = 6
36 NOBLD_BYTES_PER_EVT = 7
37 EVBLD_HITS_PER_EVT = 8
38 EVBLD_ROB_FRAC_PER_EVT = 9
39 EVBLD_BYTES_PER_EVT = 10
43 if not os.path.isfile(filename):
44 logging.warning(
"Cannot open file {}".
format(filename))
46 with open(filename)
as logfile:
47 lines = re.findall(
"{}.*$".
format(pattern),
48 logfile.read(), re.MULTILINE)
50 logging.warning(
"Could not find pattern \"{}\" in file {}".
format(pattern, filename))
59 for token
in re.split(pattern, line):
60 token = token.replace(
' ',
'')
62 split_result.append(token)
63 result.append(split_result)
68 logging.basicConfig(stream=sys.stdout,
69 format=
'%(levelname)-8s %(message)s',
74 lines =
get_lines(
r'^\s*ROS-',
'ros_hitstats_reject.txt')
78 name = row[LookUpDict.ROS_NAME]
79 hit_rate = row[LookUpDict.TOTAL_ROB_FRAC_PER_EVT]
80 data_rate = row[LookUpDict.TOTAL_BYTES_PER_EVT]
82 'hits-per-evt': hit_rate,
83 'kbytes-per-evt':
float(data_rate)/1000
87 output_file =
'extra-results.json'
88 if os.path.isfile(output_file):
89 with open(output_file)
as f:
90 data.update(json.load(f, object_pairs_hook=LastUpdatedOrderedDict))
92 data.update({
'ros-stats': ros_stats})
94 with open(output_file,
'w')
as f:
95 json.dump(data, f, indent=4)
98 if "__main__" in __name__: