From 2130eae8b1b68fbbdd939792f13c8d1e81a22cea Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 27 Apr 2022 15:45:00 -0700 Subject: [PATCH] fix panda_jungle static analysis old-commit-hash: bfeaf35d6dd2c29c65b80a70ccafd9948056731a --- tools/replay/can_replay.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/replay/can_replay.py b/tools/replay/can_replay.py index d9b0793563..7b5949c265 100755 --- a/tools/replay/can_replay.py +++ b/tools/replay/can_replay.py @@ -11,10 +11,14 @@ from common.realtime import config_realtime_process, Ratekeeper, DT_CTRL from selfdrive.boardd.boardd import can_capnp_to_can_list from tools.lib.logreader import LogReader from panda import Panda + try: - from panda_jungle import PandaJungle # pylint: disable=import-error -except Exception: - PandaJungle = None + # this bool can be replaced when mypy understands this pattern + panda_jungle_imported = True + from panda_jungle import PandaJungle # pylint: disable=import-error # type: ignore +except ImportError: + PandaJugnle = None + panda_jungle_imported = False def send_thread(s, flock): @@ -82,7 +86,7 @@ def connect(): if __name__ == "__main__": - if PandaJungle is None: + if panda_jungle_imported: print("\33[31m", "WARNING: cannot connect to jungles. Clone the jungle library to enable support:", "\033[0m") print("\033[34m", f"cd {BASEDIR} && git clone https://github.com/commaai/panda_jungle", "\033[0m")