From 446ff1794becf3621461b5ce00319a2f10e672dd Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Wed, 8 Jun 2022 08:19:48 -0400 Subject: [PATCH] flash_can: report missing pyserial Signed-off-by: Eric Callahan --- scripts/flash_can.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/flash_can.py b/scripts/flash_can.py index b787709..4da48a3 100755 --- a/scripts/flash_can.py +++ b/scripts/flash_can.py @@ -520,7 +520,13 @@ class SerialSocket: async def run(self, intf: str, baud: int, fw_path: pathlib.Path) -> None: if not fw_path.is_file(): raise FlashCanError("Invalid firmware path '%s'" % (fw_path)) - import serial + try: + import serial + except ModuleNotFoundError: + raise FlashCanError( + "The pyserial python package was not found. To install " + "run the following command in a terminal: \n\n" + " pip3 install pyserial\n\n") self.serial_error = serial.SerialException try: serial_dev = serial.Serial(baudrate=baud, timeout=0,