mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Workaround for bug in PySerial: Don't crash if file doesn't exist
Gonna report this upstream at the PySerial folks, if nobody else found this yet. Fixes Sentry issue CURA-11W.
This commit is contained in:
parent
8714ff9edb
commit
9daab5ed9b
1 changed files with 6 additions and 2 deletions
|
@ -114,10 +114,14 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
|
|||
:param only_list_usb: If true, only usb ports are listed
|
||||
"""
|
||||
base_list = []
|
||||
for port in serial.tools.list_ports.comports():
|
||||
try:
|
||||
port_list = serial.tools.list_ports.comports()
|
||||
except TypeError: # Bug in PySerial causes a TypeError if port gets disconnected while processing.
|
||||
port_list = []
|
||||
for port in port_list:
|
||||
if not isinstance(port, tuple):
|
||||
port = (port.device, port.description, port.hwid)
|
||||
if not port[2]: # HWID may be None if the port got disconnected while processing, the device is not USB or the system doesn't report the type.
|
||||
if not port[2]: # HWID may be None if the device is not USB or the system doesn't report the type.
|
||||
continue
|
||||
if only_list_usb and not port[2].startswith("USB"):
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue