mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
CommaCarSegments: BIG Database! (#31169)
* sanetized selector * god damn * add to re * slog branch * slog * source * big * not slog * cleanup * no space * works! * trigger * main! old-commit-hash: 824ddffec8c67758f3ea080c75e805d4b27f38ef
This commit is contained in:
+16
-8
@@ -72,6 +72,7 @@ class _LogFileReader:
|
||||
class ReadMode(enum.StrEnum):
|
||||
RLOG = "r" # only read rlogs
|
||||
QLOG = "q" # only read qlogs
|
||||
SANITIZED = "s" # read from the commaCarSegments database
|
||||
AUTO = "a" # default to rlogs, fallback to qlogs
|
||||
AUTO_INTERACIVE = "i" # default to rlogs, fallback to qlogs with a prompt from the user
|
||||
|
||||
@@ -169,17 +170,24 @@ def check_source(source, *args):
|
||||
try:
|
||||
files = source(*args)
|
||||
assert next(get_invalid_files(files), None) is None
|
||||
return True, files
|
||||
except Exception:
|
||||
return False, None
|
||||
return None, files
|
||||
except Exception as e:
|
||||
return e, None
|
||||
|
||||
def auto_source(*args):
|
||||
def auto_source(sr: SegmentRange, mode=ReadMode.RLOG):
|
||||
if mode == ReadMode.SANITIZED:
|
||||
return comma_car_segments_source(sr, mode)
|
||||
|
||||
exceptions = []
|
||||
# Automatically determine viable source
|
||||
for source in [comma_car_segments_source, internal_source, openpilotci_source]:
|
||||
valid, ret = check_source(source, *args)
|
||||
if valid:
|
||||
for source in [internal_source, openpilotci_source, comma_api_source, comma_car_segments_source]:
|
||||
exception, ret = check_source(source, sr, mode)
|
||||
if exception is None:
|
||||
return ret
|
||||
return comma_api_source(*args)
|
||||
else:
|
||||
exceptions.append(exception)
|
||||
|
||||
raise Exception(f"auto_source could not find any valid source, exceptions for sources: {exceptions}")
|
||||
|
||||
def parse_useradmin(identifier):
|
||||
if "useradmin.comma.ai" in identifier:
|
||||
|
||||
Reference in New Issue
Block a user