More migration to segmentrangereader (#30959)
* filter log message * ffr * gtfs * gtfs
This commit is contained in:
parent
3c74a61c97
commit
32dfb3f8f2
|
@ -1,11 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
import os
|
||||
import argparse
|
||||
import json
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from openpilot.tools.lib.logreader import LogReader
|
||||
from openpilot.tools.lib.route import Route
|
||||
from openpilot.tools.lib.srreader import SegmentRangeReader
|
||||
|
||||
LEVELS = {
|
||||
"DEBUG": 10,
|
||||
|
@ -53,31 +51,18 @@ if __name__ == "__main__":
|
|||
parser.add_argument("route", type=str, nargs='*', help="route name + segment number for offline usage")
|
||||
args = parser.parse_args()
|
||||
|
||||
logs = None
|
||||
if len(args.route):
|
||||
if os.path.exists(args.route[0]):
|
||||
logs = [args.route[0]]
|
||||
else:
|
||||
r = Route(args.route[0])
|
||||
logs = [q_log if r_log is None else r_log for (q_log, r_log) in zip(r.qlog_paths(), r.log_paths(), strict=True)]
|
||||
|
||||
if len(args.route) == 2 and logs:
|
||||
n = int(args.route[1])
|
||||
logs = [logs[n]]
|
||||
|
||||
min_level = LEVELS[args.level]
|
||||
|
||||
if logs:
|
||||
for log in logs:
|
||||
if log:
|
||||
lr = LogReader(log)
|
||||
for m in lr:
|
||||
if m.which() == 'logMessage':
|
||||
print_logmessage(m.logMonoTime, m.logMessage, min_level)
|
||||
elif m.which() == 'errorLogMessage' and 'qlog' in log:
|
||||
print_logmessage(m.logMonoTime, m.errorLogMessage, min_level)
|
||||
elif m.which() == 'androidLog':
|
||||
print_androidlog(m.logMonoTime, m.androidLog)
|
||||
if args.route:
|
||||
for route in args.route:
|
||||
lr = SegmentRangeReader(route)
|
||||
for m in lr:
|
||||
if m.which() == 'logMessage':
|
||||
print_logmessage(m.logMonoTime, m.logMessage, min_level)
|
||||
elif m.which() == 'errorLogMessage':
|
||||
print_logmessage(m.logMonoTime, m.errorLogMessage, min_level)
|
||||
elif m.which() == 'androidLog':
|
||||
print_androidlog(m.logMonoTime, m.androidLog)
|
||||
else:
|
||||
sm = messaging.SubMaster(['logMessage', 'androidLog'], addr=args.addr)
|
||||
while True:
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
from openpilot.tools.lib.route import Route
|
||||
from openpilot.tools.lib.logreader import MultiLogIterator
|
||||
from openpilot.tools.lib.srreader import ReadMode, SegmentRangeReader
|
||||
|
||||
|
||||
def get_fingerprint(lr):
|
||||
|
@ -40,6 +39,5 @@ if __name__ == "__main__":
|
|||
print("Usage: ./fingerprint_from_route.py <route>")
|
||||
sys.exit(1)
|
||||
|
||||
route = Route(sys.argv[1])
|
||||
lr = MultiLogIterator(route.log_paths()[:5])
|
||||
lr = SegmentRangeReader(sys.argv[1], mode=ReadMode.QLOG)
|
||||
get_fingerprint(lr)
|
||||
|
|
|
@ -1,26 +1,19 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
from openpilot.tools.lib.logreader import LogReader
|
||||
from openpilot.tools.lib.route import Route
|
||||
|
||||
import argparse
|
||||
from openpilot.tools.lib.srreader import SegmentRangeReader
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("route", help="The route name")
|
||||
parser.add_argument("segment", type=int, help="The index of the segment")
|
||||
args = parser.parse_args()
|
||||
|
||||
out_path = os.path.join("jpegs", f"{args.route.replace('|', '_')}_{args.segment}")
|
||||
out_path = os.path.join("jpegs", f"{args.route.replace('|', '_').replace('/', '_')}")
|
||||
os.makedirs(out_path, exist_ok=True)
|
||||
|
||||
r = Route(args.route)
|
||||
path = r.log_paths()[args.segment] or r.qlog_paths()[args.segment]
|
||||
lr = list(LogReader(path))
|
||||
lr = SegmentRangeReader(args.route)
|
||||
|
||||
for msg in tqdm(lr):
|
||||
if msg.which() == 'thumbnail':
|
||||
|
|
Loading…
Reference in New Issue