Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 15 commits into from
Feb 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions selfdrive/loggerd/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ def get_data_stats(self):
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:
Expand Down Expand Up @@ -208,7 +214,7 @@ def abort_upload(self):
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"
Expand All @@ -221,6 +227,9 @@ def upload(self, key, fn):
key += ext
fn += ext

return (key, fn)

def upload(self, key, fn):
try:
sz = os.path.getsize(fn)
except OSError:
Expand Down Expand Up @@ -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
Expand Down