Allow uploader.py to compress rlog without upload permission (#471)

* Always Compress - Make sure uploader to bzip2 rlog once it's completed without any upload permission.
pull/530/head
eFini 6 years ago committed by Nigel Armstrong
parent 03f13e614b
commit 88246af4c7
  1. 19
      selfdrive/loggerd/uploader.py

@ -134,10 +134,16 @@ class Uploader(object):
total_size += os.stat(fn).st_size
return dict(name_counts), total_size
def next_file_to_compress(self):
for name, key, fn in self.gen_upload_files():
if name == "rlog":
return (key, fn, 0)
return None
def next_file_to_upload(self, with_video):
# try to upload log files first
for name, key, fn in self.gen_upload_files():
if name in ["rlog", "rlog.bz2"]:
if name == "rlog.bz2":
return (key, fn, 0)
if with_video:
@ -208,7 +214,7 @@ class Uploader(object):
raise_on_thread(thread, SystemExit)
thread.join()
def upload(self, key, fn):
def compress(self, key, fn):
# write out the bz2 compress
if fn.endswith("log"):
ext = ".bz2"
@ -221,6 +227,9 @@ class Uploader(object):
key += ext
fn += ext
return (key, fn)
def upload(self, key, fn):
try:
sz = os.path.getsize(fn)
except OSError:
@ -275,6 +284,12 @@ def uploader_fn(exit_event):
if exit_event.is_set():
return
d = uploader.next_file_to_compress()
if d is not None:
key, fn, _ = d
uploader.compress(key, fn)
continue
if not should_upload:
time.sleep(5)
continue

Loading…
Cancel
Save