From c37d47885774e440414b25b44764174a42d25884 Mon Sep 17 00:00:00 2001 From: EulalieCoevoet Date: Fri, 18 Oct 2024 20:03:47 +0200 Subject: [PATCH] [splib3] serialport: fixes case of NoneType entry (#126) --- python3/src/splib3/interface/serialport.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python3/src/splib3/interface/serialport.py b/python3/src/splib3/interface/serialport.py index 78d087f..07fb7de 100644 --- a/python3/src/splib3/interface/serialport.py +++ b/python3/src/splib3/interface/serialport.py @@ -13,17 +13,17 @@ def getDevicePort(entry, method="manufacturer"): ports = [] comports = serial.tools.list_ports.comports() - if comports is None: + if comports is None or len(comports) == 0: Sofa.msg_error("stlib3.interface.serialport", "Serial ports check failed, list of ports is empty.") return if method == "manufacturer": - ports = [p for p in comports if entry in p.manufacturer] + ports = [p for p in comports if p.manufacturer is not None and entry in p.manufacturer] if method == "description": - ports = [p for p in comports if entry in p.description] + ports = [p for p in comports if p.description is not None and entry in p.description] if method == "serial_number": - ports = [p for p in comports if entry in p.serial_number] + ports = [p for p in comports if p.serial_number is not None and entry in p.serial_number] if not ports: Sofa.msg_error("stlib3.interface.serialport",