FileName clean up (#35938)

two spaces!
pull/35939/head
Shane Smiskol 2 days ago committed by GitHub
parent 839a773345
commit 52a4b52628
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      tools/lib/logreader.py
  2. 18
      tools/lib/route.py

@ -102,7 +102,8 @@ class ReadMode(enum.StrEnum):
LogPath = str | None LogPath = str | None
Source = Callable[[SegmentRange, tuple[str, ...]], list[LogPath]] LogFileName = tuple[str, ...]
Source = Callable[[SegmentRange, LogFileName], list[LogPath]]
InternalUnavailableException = Exception("Internal source not available") InternalUnavailableException = Exception("Internal source not available")
@ -111,7 +112,7 @@ class LogsUnavailable(Exception):
pass pass
def comma_api_source(sr: SegmentRange, fns: tuple[str, ...]) -> list[LogPath]: def comma_api_source(sr: SegmentRange, fns: LogFileName) -> list[LogPath]:
route = Route(sr.route_name) route = Route(sr.route_name)
# comma api will have already checked if the file exists # comma api will have already checked if the file exists
@ -121,7 +122,7 @@ def comma_api_source(sr: SegmentRange, fns: tuple[str, ...]) -> list[LogPath]:
return [route.qlog_paths()[seg] for seg in sr.seg_idxs] return [route.qlog_paths()[seg] for seg in sr.seg_idxs]
def internal_source(sr: SegmentRange, fns: tuple[str, ...], endpoint_url: str = DATA_ENDPOINT) -> list[LogPath]: def internal_source(sr: SegmentRange, fns: LogFileName, endpoint_url: str = DATA_ENDPOINT) -> list[LogPath]:
if not internal_source_available(endpoint_url): if not internal_source_available(endpoint_url):
raise InternalUnavailableException raise InternalUnavailableException
@ -131,11 +132,11 @@ def internal_source(sr: SegmentRange, fns: tuple[str, ...], endpoint_url: str =
return eval_source([[get_internal_url(sr, seg, fn) for fn in fns] for seg in sr.seg_idxs]) return eval_source([[get_internal_url(sr, seg, fn) for fn in fns] for seg in sr.seg_idxs])
def openpilotci_source(sr: SegmentRange, fns: tuple[str, ...]) -> list[LogPath]: def openpilotci_source(sr: SegmentRange, fns: LogFileName) -> list[LogPath]:
return eval_source([[get_url(sr.route_name, seg, fn) for fn in fns] for seg in sr.seg_idxs]) return eval_source([[get_url(sr.route_name, seg, fn) for fn in fns] for seg in sr.seg_idxs])
def comma_car_segments_source(sr: SegmentRange, fns: tuple[str, ...]) -> list[LogPath]: def comma_car_segments_source(sr: SegmentRange, fns: LogFileName) -> list[LogPath]:
return eval_source([get_comma_segments_url(sr.route_name, seg) for seg in sr.seg_idxs]) return eval_source([get_comma_segments_url(sr.route_name, seg) for seg in sr.seg_idxs])

@ -1,7 +1,6 @@
import os import os
import re import re
import requests import requests
from typing import TypeAlias
from functools import cache from functools import cache
from urllib.parse import urlparse from urllib.parse import urlparse
from collections import defaultdict from collections import defaultdict
@ -11,15 +10,16 @@ from openpilot.tools.lib.auth_config import get_token
from openpilot.tools.lib.api import APIError, CommaApi from openpilot.tools.lib.api import APIError, CommaApi
from openpilot.tools.lib.helpers import RE from openpilot.tools.lib.helpers import RE
FileNameTuple: TypeAlias = tuple[str, ...]
class FileName: class FileName:
RLOG: FileNameTuple = ("rlog.zst", "rlog.bz2") RLOG = ("rlog.zst", "rlog.bz2")
QLOG: FileNameTuple = ("qlog.zst", "qlog.bz2") QLOG = ("qlog.zst", "qlog.bz2")
QCAMERA: FileNameTuple = ('qcamera.ts',) QCAMERA = ('qcamera.ts',)
FCAMERA: FileNameTuple = ('fcamera.hevc',) FCAMERA = ('fcamera.hevc',)
ECAMERA: FileNameTuple = ('ecamera.hevc',) ECAMERA = ('ecamera.hevc',)
DCAMERA: FileNameTuple = ('dcamera.hevc',) DCAMERA = ('dcamera.hevc',)
BOOTLOG: FileNameTuple = ('bootlog.zst', 'bootlog.bz2') BOOTLOG = ('bootlog.zst', 'bootlog.bz2')
class Route: class Route:
def __init__(self, name, data_dir=None): def __init__(self, name, data_dir=None):

Loading…
Cancel
Save