Skip to content

Commit 4cd3c8b

Browse files
committed
Fix ordering.
1 parent 7f99c46 commit 4cd3c8b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

scripts/irpmon/irpmon_to_json.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,19 +328,27 @@ def communication(self):
328328
combined = self.read.communication()
329329
combined.extend(self.write.communication())
330330

331-
combined.sort(key=lambda x: x[1].id)
331+
combined.sort(key=lambda x: x[1].index)
332332

333333
# Now we no longer need the irp relations.
334334
return [x[0] for x in combined]
335335

336336

337337
# Helper to hold the relevant fields from the log records.
338338
Irp = namedtuple("Irp", [
339-
"id",
339+
# The index of this Irp record in the original file.
340+
"index",
341+
# The irp id, this seems to wrap around.
342+
"irp_id",
343+
# Major function
340344
"function",
345+
# Time string
341346
"time",
347+
# Status a reported in IOSB.Status constant
342348
"status",
349+
# IRP address, to track start and finish
343350
"address",
351+
# Data of the request.
344352
"data",
345353
])
346354

@@ -383,6 +391,7 @@ def parse_log_file(file):
383391

384392
records = []
385393

394+
irp_index = 0
386395
for line_nr, line in enumerate(file):
387396
if line.startswith("ID ="):
388397
irp_id = int(line.split('=', 1)[1].strip())
@@ -411,7 +420,8 @@ def parse_log_file(file):
411420

412421
if not discard:
413422
record = Irp(
414-
id = irp_id,
423+
index = irp_index,
424+
irp_id = irp_id,
415425
function = function,
416426
time = curtime,
417427
status = status_constant,
@@ -423,6 +433,7 @@ def parse_log_file(file):
423433
data = False
424434
discard = False
425435
lines = []
436+
irp_index += 1
426437

427438
return records
428439

@@ -474,7 +485,7 @@ def parse_json_file(path):
474485

475486
records = []
476487
# Now we have good and clean data.
477-
for entry in irp_entries:
488+
for irp_index, entry in enumerate(irp_entries):
478489
if entry.get("Driver name") != TARGET_DRIVER:
479490
continue
480491

@@ -494,7 +505,8 @@ def parse_json_file(path):
494505
status_constant = Status[entry.get("IOSB.Status constant")]
495506
irp_address = int(entry.get("IRP address"), 0)
496507
record = Irp(
497-
id = irp_id,
508+
index = irp_index,
509+
irp_id = irp_id,
498510
function = function,
499511
time = curtime,
500512
status = status_constant,

0 commit comments

Comments
 (0)