evil-mad / plotink

Common files for Inkscape extensions to drive EggBot, WaterColorBot, and similar plotter-type machines
MIT License
42 stars 29 forks source link

ebb_serial: Catch exception in comports #38

Closed oskay closed 3 years ago

oskay commented 3 years ago

When comports has an error, we should handle that error gracefully.

Partial traceback:

  File "/home/ubuntu/.config/inkscape/extensions/axidraw_deps/plotink/ebb_serial.py", line 57, in findPort

    com_ports_list = list(comports())

  File "/home/ubuntu/.config/inkscape/extensions/axidraw_deps/serial/tools/list_ports_linux.py", line 102, in comports

    for info in [SysFS(d) for d in devices]

  File "/home/ubuntu/.config/inkscape/extensions/axidraw_deps/serial/tools/list_ports_linux.py", line 102, in <listcomp>

    for info in [SysFS(d) for d in devices]

  File "/home/ubuntu/.config/inkscape/extensions/axidraw_deps/serial/tools/list_ports_linux.py", line 48, in __init__

    num_if = int(self.read_line(self.usb_device_path, 'bNumInterfaces'))

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

The TypeError itself is https://github.com/pyserial/pyserial/issues/550 and occurs whenever no ports are found on Linux.

oskay commented 3 years ago

Patch added in 1.3