diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..6a97c00622 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +sudo: required + +services: + - docker + +install: + - docker build -t tmppilot -f Dockerfile.openpilot . + +script: + - docker run --rm + -v "$(pwd)"/selfdrive/test/plant/out:/tmp/openpilot/selfdrive/test/plant/out + tmppilot /bin/sh -c 'cd /tmp/openpilot/selfdrive/test/plant && ./runtest.sh' + diff --git a/RELEASES.md b/RELEASES.md index 0f784c9e67..664ccd5c27 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,9 @@ +Version 0.2.3 (2017-01-11) +=========================== + * Reduce space usage by 80% + * Add better logging + * Add Travis CI + Version 0.2.2 (2017-01-10) =========================== * Board triggers started signal on CAN messages diff --git a/selfdrive/common/version.h b/selfdrive/common/version.h index 56fdca585a..fc442273c3 100644 --- a/selfdrive/common/version.h +++ b/selfdrive/common/version.h @@ -1 +1 @@ -const char *openpilot_version = "0.2.2"; +const char *openpilot_version = "0.2.3"; diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py index e70034c1ae..ab3d595fb0 100755 --- a/selfdrive/loggerd/uploader.py +++ b/selfdrive/loggerd/uploader.py @@ -9,11 +9,14 @@ import requests import traceback import threading +from collections import Counter from selfdrive.swaglog import cloudlog from selfdrive.loggerd.config import get_dongle_id_and_secret, ROOT from common.api import api_get +fake_upload = os.getenv("FAKEUPLOAD") is not None + def raise_on_thread(t, exctype): for ctid, tobj in threading._active.items(): if tobj is t: @@ -98,6 +101,14 @@ class Uploader(object): yield (name, key, fn) + def get_data_stats(self): + name_counts = Counter() + total_size = 0 + for name, key, fn in self.gen_upload_files(): + name_counts[name] += 1 + total_size += os.stat(fn).st_size + return dict(name_counts), total_size + def next_file_to_upload(self): # try to upload log files first for name, key, fn in self.gen_upload_files(): @@ -120,8 +131,15 @@ class Uploader(object): url = url_resp.text cloudlog.info({"upload_url", url}) - with open(fn, "rb") as f: - self.last_resp = requests.put(url, data=f) + if fake_upload: + print "*** WARNING, THIS IS A FAKE UPLOAD TO %s ***" % url + class FakeResponse(object): + def __init__(self): + self.status_code = 200 + self.last_resp = FakeResponse() + else: + with open(fn, "rb") as f: + self.last_resp = requests.put(url, data=f) except Exception as e: self.last_exc = (e, traceback.format_exc()) raise diff --git a/selfdrive/logmessaged.py b/selfdrive/logmessaged.py index 2e49df417c..0dbe6373fb 100755 --- a/selfdrive/logmessaged.py +++ b/selfdrive/logmessaged.py @@ -6,7 +6,7 @@ import selfdrive.messaging as messaging def main(gctx): # setup logentries. we forward log messages to it - le_token = "bc65354a-b887-4ef4-8525-15dd51230e8c" + le_token = "e8549616-0798-4d7e-a2ca-2513ae81fa17" le_handler = LogentriesHandler(le_token, use_tls=False) le_level = 20 #logging.INFO diff --git a/selfdrive/manager.py b/selfdrive/manager.py index 5e6f8b909a..ca2ef87345 100755 --- a/selfdrive/manager.py +++ b/selfdrive/manager.py @@ -18,6 +18,7 @@ from selfdrive.swaglog import cloudlog import selfdrive.messaging as messaging from selfdrive.thermal import read_thermal from selfdrive.registration import register +from selfdrive.loggerd.uploader import Uploader import common.crash @@ -131,7 +132,7 @@ def cleanup_all_processes(signal, frame): # ****************** run loop ****************** def manager_init(): - global gctx + global gctx, fake_uploader reg_res = register() if reg_res: @@ -147,6 +148,8 @@ def manager_init(): cloudlog.bind_global(dongle_id=dongle_id) common.crash.bind_user(dongle_id=dongle_id) + fake_uploader = Uploader(dongle_id, dongle_secret, ROOT) + # set gctx gctx = { "calibration": { @@ -162,7 +165,10 @@ def manager_thread(): thermal_sock = messaging.pub_sock(context, service_list['thermal'].port) health_sock = messaging.sub_sock(context, service_list['health'].port) - cloudlog.info("manager start") + version = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "common", "version.h")).read().split('"')[1] + + cloudlog.info("manager start %s" % version) + cloudlog.info(dict(os.environ)) start_managed_process("logmessaged") start_managed_process("logcatd") @@ -186,6 +192,8 @@ def manager_thread(): logger_dead = False + count = 0 + while 1: # get health of board, log this in "thermal" td = messaging.recv_sock(health_sock, wait=True) @@ -235,6 +243,13 @@ def manager_thread(): for p in running: cloudlog.debug(" running %s %s" % (p, running[p])) + # report to server once per minute + if (count%60) == 0: + names, total_size = fake_uploader.get_data_stats() + cloudlog.info({"names": names, "total_size": total_size, "running": running.keys(), "count": count, "health": td.to_dict(), "thermal": msg.to_dict(), "version": version, "nonce": "THIS_STATUS_PACKET"}) + + count += 1 + # optional, build the c++ binaries and preimport the python for speed def manager_prepare(): diff --git a/selfdrive/visiond/visiond b/selfdrive/visiond/visiond index e09e89b0c0..235c5870a5 100755 --- a/selfdrive/visiond/visiond +++ b/selfdrive/visiond/visiond @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:96a2348cd55441552836cf5f196e535f5ec61c27879c548fb8bcb9b688079b9b +oid sha256:fa55f398631e8831c45a93e32e00909d2464c80a263fdede974fcf030e5085cc size 14723648