diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2014-08-01 01:38:04 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2014-08-01 01:38:04 +0000 |
commit | 0e4a30ef0c5d37fd2555bd705e3c1e2c105e05e9 (patch) | |
tree | 07d4225e5080948a4126f4b9d0996ec12d01b1a2 | |
parent | a45b3419fdca7924023064366dfc6afdf98093cd (diff) | |
download | pyserial-git-0e4a30ef0c5d37fd2555bd705e3c1e2c105e05e9.tar.gz |
[Bug pyserial:163] serial.tools.list_ports.grep() fails if it encounters None type
-rw-r--r-- | pyserial/CHANGES.txt | 5 | ||||
-rw-r--r-- | pyserial/serial/tools/list_ports_osx.py | 38 |
2 files changed, 25 insertions, 18 deletions
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt index 5741b40..d31c6d2 100644 --- a/pyserial/CHANGES.txt +++ b/pyserial/CHANGES.txt @@ -485,3 +485,8 @@ Version 2.8 2014-xx-xx Bugfixes: - [Bug pyserial:166] RFC2217 connections always fail + +Bugfixes (posix): + +- [Bug pyserial:163] serial.tools.list_ports.grep() fails if it encounters None type + diff --git a/pyserial/serial/tools/list_ports_osx.py b/pyserial/serial/tools/list_ports_osx.py index c9ed615..242f468 100644 --- a/pyserial/serial/tools/list_ports_osx.py +++ b/pyserial/serial/tools/list_ports_osx.py @@ -180,24 +180,26 @@ def comports(): info = [] # First, add the callout device file. - info.append(get_string_property(service, "IOCalloutDevice")) - - # If the serial port is implemented by a - usb_device = GetParentDeviceByType(service, "IOUSBDevice") - if usb_device != None: - info.append(get_string_property(usb_device, "USB Product Name")) - - info.append( - "USB VID:PID=%x:%x SNR=%s"%( - get_int_property(usb_device, "idVendor"), - get_int_property(usb_device, "idProduct"), - get_string_property(usb_device, "USB Serial Number")) - ) - else: - info.append('n/a') - info.append('n/a') - - ports.append(info) + device = get_string_property(service, "IOCalloutDevice") + if device: + info.append(device) + + # If the serial port is implemented by a + usb_device = GetParentDeviceByType(service, "IOUSBDevice") + if usb_device is not None: + info.append(get_string_property(usb_device, "USB Product Name") or 'n/a') + + info.append( + "USB VID:PID=%x:%x SNR=%s"%( + get_int_property(usb_device, "idVendor"), + get_int_property(usb_device, "idProduct"), + get_string_property(usb_device, "USB Serial Number")) + ) + else: + info.append('n/a') + info.append('n/a') + + ports.append(info) return ports |