mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-05 05:22:07 +08:00
allow uploads
This commit is contained in:
@@ -103,6 +103,7 @@ log_recv_queue: Queue[str] = queue.Queue()
|
||||
cancelled_uploads: set[str] = set()
|
||||
|
||||
cur_upload_items: dict[int, UploadItem | None] = {}
|
||||
params_store = Params()
|
||||
|
||||
|
||||
def strip_bz2_extension(fn: str) -> str:
|
||||
@@ -115,6 +116,10 @@ class AbortTransferException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def always_allow_uploads() -> bool:
|
||||
return params_store.get_bool("AlwaysAllowUploads")
|
||||
|
||||
|
||||
class UploadQueueCache:
|
||||
|
||||
@staticmethod
|
||||
@@ -214,7 +219,7 @@ def cb(sm, item, tid, end_event: threading.Event, sz: int, cur: int) -> None:
|
||||
# or if athenad is shutting down to re-connect the websocket
|
||||
sm.update(0)
|
||||
metered = sm['deviceState'].networkMetered
|
||||
if metered and (not item.allow_cellular):
|
||||
if metered and (not item.allow_cellular) and not always_allow_uploads():
|
||||
raise AbortTransferException
|
||||
|
||||
if end_event.is_set():
|
||||
@@ -247,7 +252,7 @@ def upload_handler(end_event: threading.Event) -> None:
|
||||
sm.update(0)
|
||||
metered = sm['deviceState'].networkMetered
|
||||
network_type = sm['deviceState'].networkType.raw
|
||||
if metered and (not item.allow_cellular):
|
||||
if metered and (not item.allow_cellular) and not always_allow_uploads():
|
||||
retry_upload(tid, end_event, False)
|
||||
continue
|
||||
|
||||
|
||||
@@ -258,15 +258,16 @@ def main(exit_event: threading.Event = None) -> None:
|
||||
|
||||
while not exit_event.is_set():
|
||||
sm.update(0)
|
||||
always_allow_uploads = params.get_bool("AlwaysAllowUploads")
|
||||
offroad = params.get_bool("IsOffroad")
|
||||
network_type = sm['deviceState'].networkType if not force_wifi else NetworkType.wifi
|
||||
at_home = offroad and network_type in (NetworkType.ethernet, NetworkType.wifi) or not frogpilot_toggles.no_onroad_uploads
|
||||
if network_type == NetworkType.none or not at_home:
|
||||
at_home = always_allow_uploads or (offroad and network_type in (NetworkType.ethernet, NetworkType.wifi)) or not frogpilot_toggles.no_onroad_uploads
|
||||
if ((network_type == NetworkType.none) and not always_allow_uploads) or not at_home:
|
||||
if allow_sleep:
|
||||
time.sleep(60 if offroad else 5)
|
||||
continue
|
||||
|
||||
success = uploader.step(sm['deviceState'].networkType.raw, sm['deviceState'].networkMetered)
|
||||
success = uploader.step(sm['deviceState'].networkType.raw, sm['deviceState'].networkMetered and not always_allow_uploads)
|
||||
if success is None:
|
||||
backoff = 60 if offroad else 5
|
||||
elif success:
|
||||
|
||||
@@ -52,7 +52,7 @@ def allow_logging(started, params, CP: car.CarParams, classic_model, tinygrad_mo
|
||||
return not frogpilot_toggles.no_logging and logging(started, params, CP, classic_model, tinygrad_model, frogpilot_toggles)
|
||||
|
||||
def allow_uploads(started, params, CP: car.CarParams, classic_model, tinygrad_model, frogpilot_toggles) -> bool:
|
||||
return not frogpilot_toggles.no_uploads or frogpilot_toggles.no_onroad_uploads
|
||||
return params.get_bool("AlwaysAllowUploads") or not frogpilot_toggles.no_uploads or frogpilot_toggles.no_onroad_uploads
|
||||
|
||||
def run_classic_modeld(started, params, CP: car.CarParams, classic_model, tinygrad_model, frogpilot_toggles) -> bool:
|
||||
return started and classic_model
|
||||
|
||||
Reference in New Issue
Block a user