mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-19 10:03:57 +08:00
fix restricting video upload to wifi
This commit is contained in:
@@ -248,33 +248,30 @@ def uploader_fn(exit_event):
|
||||
|
||||
uploader = Uploader(dongle_id, access_token, ROOT)
|
||||
|
||||
backoff = 0.1
|
||||
while True:
|
||||
|
||||
upload_video = (params.get("IsUploadVideoOverCellularEnabled") != "0") or is_on_wifi()
|
||||
|
||||
backoff = 0.1
|
||||
while True:
|
||||
if exit_event.is_set():
|
||||
return
|
||||
|
||||
if exit_event.is_set():
|
||||
return
|
||||
d = uploader.next_file_to_upload(upload_video)
|
||||
if d is None:
|
||||
time.sleep(5)
|
||||
continue
|
||||
|
||||
d = uploader.next_file_to_upload(upload_video)
|
||||
if d is None:
|
||||
break
|
||||
key, fn, _ = d
|
||||
|
||||
key, fn, _ = d
|
||||
|
||||
cloudlog.info("to upload %r", d)
|
||||
success = uploader.upload(key, fn)
|
||||
if success:
|
||||
backoff = 0.1
|
||||
else:
|
||||
cloudlog.info("backoff %r", backoff)
|
||||
time.sleep(backoff + random.uniform(0, backoff))
|
||||
backoff = min(backoff*2, 120)
|
||||
cloudlog.info("upload done, success=%r", success)
|
||||
|
||||
time.sleep(5)
|
||||
cloudlog.info("to upload %r", d)
|
||||
success = uploader.upload(key, fn)
|
||||
if success:
|
||||
backoff = 0.1
|
||||
else:
|
||||
cloudlog.info("backoff %r", backoff)
|
||||
time.sleep(backoff + random.uniform(0, backoff))
|
||||
backoff = min(backoff*2, 120)
|
||||
cloudlog.info("upload done, success=%r", success)
|
||||
|
||||
def main(gctx=None):
|
||||
uploader_fn(threading.Event())
|
||||
|
||||
Reference in New Issue
Block a user