diff --git a/lgtm.yml b/lgtm.yml index 288d1a3b8..341a78808 100644 --- a/lgtm.yml +++ b/lgtm.yml @@ -1,3 +1,9 @@ +path_classifiers: + library: + - external + - phonelibs + - pyextra + - tools/lib/mkvparse extraction: cpp: after_prepare: diff --git a/selfdrive/common/visionipc.c b/selfdrive/common/visionipc.c index b05365890..a9c4e8a13 100644 --- a/selfdrive/common/visionipc.c +++ b/selfdrive/common/visionipc.c @@ -99,7 +99,7 @@ int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, Visi close(s->ipc_fd); return -1; } - assert(rp.type = VIPC_STREAM_BUFS); + assert(rp.type == VIPC_STREAM_BUFS); assert(rp.d.stream_bufs.type == type); s->bufs_info = rp.d.stream_bufs; diff --git a/selfdrive/debug/internal/cycle_alerts.py b/selfdrive/debug/internal/cycle_alerts.py index 20b0a8dd4..cc073aaa2 100644 --- a/selfdrive/debug/internal/cycle_alerts.py +++ b/selfdrive/debug/internal/cycle_alerts.py @@ -3,10 +3,8 @@ import argparse import time -import zmq import cereal.messaging as messaging -from cereal.services import service_list from selfdrive.controls.lib.alerts import ALERTS def now_millis(): return time.time() * 1000 diff --git a/selfdrive/debug/internal/sensor_test_bootloop.py b/selfdrive/debug/internal/sensor_test_bootloop.py index 4b6e993e7..3755221d2 100755 --- a/selfdrive/debug/internal/sensor_test_bootloop.py +++ b/selfdrive/debug/internal/sensor_test_bootloop.py @@ -19,7 +19,7 @@ except PermissionError: try: with open('/tmp/test-results.json', 'r') as infile: data = json.load(infile) -except: +except Exception: data = {'sensor-pass': 0, 'sensor-fail': 0} STARTUP_SCRIPT = "/data/data/com.termux/files/continue.sh" @@ -27,7 +27,7 @@ try: with open(STARTUP_SCRIPT, 'w') as startup_script: startup_script.write("#!/usr/bin/bash\n\n/data/openpilot/selfdrive/test/sensor_test_bootloop.py\n") os.chmod(STARTUP_SCRIPT, stat.S_IRWXU) -except: +except Exception: print("Failed to install new startup script -- aborting") sys.exit(-1) diff --git a/selfdrive/locationd/liblocationd_py.py b/selfdrive/locationd/liblocationd_py.py index 9a56ecc7a..d9f71b8c3 100644 --- a/selfdrive/locationd/liblocationd_py.py +++ b/selfdrive/locationd/liblocationd_py.py @@ -1,9 +1,7 @@ import os -import subprocess from common.basedir import BASEDIR from cffi import FFI -from ctypes import cdll locationd_dir = os.path.dirname(os.path.abspath(__file__)) liblocationd_fn = os.path.join(locationd_dir, "liblocationd.so") diff --git a/selfdrive/modeld/runners/snpemodel.cc b/selfdrive/modeld/runners/snpemodel.cc index 084a7c772..4bb442d5e 100644 --- a/selfdrive/modeld/runners/snpemodel.cc +++ b/selfdrive/modeld/runners/snpemodel.cc @@ -28,7 +28,7 @@ SNPEModel::SNPEModel(const char *path, float *output, size_t output_size, int ru // load model std::unique_ptr container = zdl::DlContainer::IDlContainer::open(model_data, model_size); if (!container) { PrintErrorStringAndExit(); } - printf("loaded model with size: %u\n", model_size); + printf("loaded model with size: %lu\n", model_size); // create model runner zdl::SNPE::SNPEBuilder snpeBuilder(container.get()); @@ -79,7 +79,7 @@ SNPEModel::SNPEModel(const char *path, float *output, size_t output_size, int ru stride *= bufferShape[i]; strides[i-1] = stride; } - printf("input product is %u\n", product); + printf("input product is %lu\n", product); inputBuffer = ubFactory.createUserBuffer(NULL, product*sizeof(float), strides, &userBufferEncodingFloat); inputMap.add(input_tensor_name, inputBuffer.get()); diff --git a/tools/carcontrols/debug_controls.py b/tools/carcontrols/debug_controls.py index 9ce98568d..afb02a09a 100755 --- a/tools/carcontrols/debug_controls.py +++ b/tools/carcontrols/debug_controls.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -import struct from common.numpy_fast import clip from common.params import Params from copy import copy diff --git a/tools/carcontrols/joystickd.py b/tools/carcontrols/joystickd.py index 58235f450..b262694e6 100755 --- a/tools/carcontrols/joystickd.py +++ b/tools/carcontrols/joystickd.py @@ -7,10 +7,8 @@ ### this process needs pygame and can't run on the EON ### import pygame -import zmq import cereal.messaging as messaging - def joystick_thread(): joystick_sock = messaging.pub_sock('testJoystick') diff --git a/tools/lib/api.py b/tools/lib/api.py index 4f9c87056..3323a0316 100644 --- a/tools/lib/api.py +++ b/tools/lib/api.py @@ -1,4 +1,3 @@ -import sys import os import requests from tools.lib.auth_config import clear_token diff --git a/tools/lib/auth.py b/tools/lib/auth.py index f020f83db..57e0eb0ae 100755 --- a/tools/lib/auth.py +++ b/tools/lib/auth.py @@ -1,12 +1,8 @@ #!/usr/bin/env python3 - -import json -import os import sys import webbrowser from http.server import HTTPServer, BaseHTTPRequestHandler from urllib.parse import urlencode, parse_qs -from common.file_helpers import mkdirs_exists_ok from tools.lib.api import CommaApi, APIError from tools.lib.auth_config import set_token diff --git a/tools/lib/framereader.py b/tools/lib/framereader.py index f9c070b0b..a3def5748 100644 --- a/tools/lib/framereader.py +++ b/tools/lib/framereader.py @@ -1,8 +1,6 @@ import os import sys -import glob import json -import time import struct import tempfile import threading diff --git a/tools/lib/logreader.py b/tools/lib/logreader.py index 176049452..3a25ef21b 100755 --- a/tools/lib/logreader.py +++ b/tools/lib/logreader.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import os import sys -import json import bz2 import tempfile import subprocess diff --git a/tools/nui/get_files_comma_api.py b/tools/nui/get_files_comma_api.py index 83fb73561..55b7788b3 100644 --- a/tools/nui/get_files_comma_api.py +++ b/tools/nui/get_files_comma_api.py @@ -1,5 +1,4 @@ import json -import os import sys from tools.lib.route import Route @@ -11,4 +10,4 @@ data_dump = { "logs":routes.log_paths() } -json.dump(data_dump, open("routes.json", "w")) \ No newline at end of file +json.dump(data_dump, open("routes.json", "w")) diff --git a/tools/replay/camera.py b/tools/replay/camera.py index ab0f5f8c4..c312f5273 100755 --- a/tools/replay/camera.py +++ b/tools/replay/camera.py @@ -10,7 +10,6 @@ import pygame import numpy as np import cv2 import sys -from tools.lib.lazy_property import lazy_property import cereal.messaging as messaging _BB_OFFSET = 0, 0 diff --git a/tools/replay/rqplot.py b/tools/replay/rqplot.py index 32e9a3498..3c3c5239c 100755 --- a/tools/replay/rqplot.py +++ b/tools/replay/rqplot.py @@ -1,12 +1,10 @@ #!/usr/bin/env python -import os import sys import matplotlib.pyplot as plt import numpy as np import cereal.messaging as messaging import time - # tool to plot one or more signals live. Call ex: #./rqplot.py log.carState.vEgo log.carState.aEgo diff --git a/tools/replay/unlogger.py b/tools/replay/unlogger.py index 227091fb2..52294c555 100755 --- a/tools/replay/unlogger.py +++ b/tools/replay/unlogger.py @@ -4,10 +4,7 @@ import os import sys import zmq import time -import gc import signal -from threading import Thread -import numpy as np from uuid import uuid4 from collections import namedtuple from collections import deque @@ -22,7 +19,6 @@ from cereal.services import service_list from cereal.messaging import pub_sock, MultiplePublishersError from common import realtime -from tools.lib.file_helpers import mkdirs_exists_ok from tools.lib.kbhit import KBHit from tools.lib.logreader import MultiLogIterator from tools.lib.route import Route diff --git a/tools/streamer/streamerd.py b/tools/streamer/streamerd.py index 8788eafd2..6ce940afc 100755 --- a/tools/streamer/streamerd.py +++ b/tools/streamer/streamerd.py @@ -1,15 +1,10 @@ #!/usr/bin/env python import os import sys -import argparse import zmq -import json import cv2 import numpy as np -from hexdump import hexdump -import scipy.misc import struct -from collections import deque # sudo pip install git+git://github.com/mikeboers/PyAV.git import av