From de4c543e63dbd8051fafde8cf8568b0fad8d4a39 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Mon, 12 Oct 2020 13:12:01 -0700 Subject: [PATCH] remove hotspot exceptions in uploader (#2319) * remove hotspot exceptions * skip net check while onroad old-commit-hash: ee37d03c1ffa76d91d7085c2eb9ca2ce762ee647 --- selfdrive/loggerd/uploader.py | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py index 08c1f323ec..456712f2bc 100644 --- a/selfdrive/loggerd/uploader.py +++ b/selfdrive/loggerd/uploader.py @@ -4,14 +4,11 @@ import inspect import json import os import random -import re -import subprocess +import requests import threading import time import traceback -import requests - from cereal import log from common.hardware import HARDWARE from common.api import Api @@ -74,16 +71,6 @@ def clear_locks(root): def is_on_wifi(): return HARDWARE.get_network_type() == NetworkType.wifi -def is_on_hotspot(): - try: - result = subprocess.check_output(["ifconfig", "wlan0"], stderr=subprocess.STDOUT, encoding='utf8') - result = re.findall(r"inet addr:((\d+\.){3}\d+)", result)[0][0] - return (result.startswith('192.168.43.') or # android - result.startswith('172.20.10.') or # ios - result.startswith('10.0.2.')) # toyota entune - except Exception: - return False - class Uploader(): def __init__(self, dongle_id, root): self.dongle_id = dongle_id @@ -238,25 +225,22 @@ def uploader_fn(exit_event): backoff = 0.1 counter = 0 - should_upload = False + on_wifi = False while not exit_event.is_set(): offroad = params.get("IsOffroad") == b'1' allow_raw_upload = (params.get("IsUploadRawEnabled") != b"0") and offroad - check_network = (counter % 12 == 0 if offroad else True) - if check_network: - on_hotspot = is_on_hotspot() + if offroad and counter % 12 == 0: on_wifi = is_on_wifi() - should_upload = on_wifi and not on_hotspot - - d = uploader.next_file_to_upload(with_raw=allow_raw_upload and should_upload) counter += 1 + + d = uploader.next_file_to_upload(with_raw=allow_raw_upload and on_wifi and offroad) if d is None: # Nothing to upload time.sleep(60 if offroad else 5) continue key, fn = d - cloudlog.event("uploader_netcheck", is_on_hotspot=on_hotspot, is_on_wifi=on_wifi) + cloudlog.event("uploader_netcheck", is_on_wifi=on_wifi) cloudlog.info("to upload %r", d) success = uploader.upload(key, fn) if success: