summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2009-07-21 22:12:16 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2009-07-21 22:12:16 +0000
commit9147c4483023afbea4cc0bebf55c72dfc264c9e2 (patch)
treec6f3c8314c6d264bee906fdd04aad0095e609e9a
parent512595f056037b2a70bc5a5ed9cf66bee8028e9b (diff)
downloadpyserial-git-9147c4483023afbea4cc0bebf55c72dfc264c9e2.tar.gz
implement SF 2392892
-rw-r--r--pyserial/CHANGES.txt1
-rw-r--r--pyserial/examples/scanwin32.py13
-rw-r--r--pyserial/serial/serialutil.py2
3 files changed, 11 insertions, 5 deletions
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt
index 4c93c10..22bf7aa 100644
--- a/pyserial/CHANGES.txt
+++ b/pyserial/CHANGES.txt
@@ -318,3 +318,4 @@ Bugfixes (win32):
- [Bug 2469098] parity PARITY_MARK, PARITY_SPACE isn't supported on win32
- [SF 2446218] outWaiting implemented
+- [Bug 2392892] scanwin32.py better exception handling
diff --git a/pyserial/examples/scanwin32.py b/pyserial/examples/scanwin32.py
index eb5f544..43316ac 100644
--- a/pyserial/examples/scanwin32.py
+++ b/pyserial/examples/scanwin32.py
@@ -172,7 +172,10 @@ def comports(available_only=True):
# Ignore ERROR_INSUFFICIENT_BUFFER
if ctypes.GetLastError() != ERROR_INSUFFICIENT_BUFFER:
raise ctypes.WinError()
- port_name = re.search(r"\((.*)\)", szFriendlyName.value).group(1)
+ try:
+ port_name = re.search(r"\((.*)\)", szFriendlyName.value).group(1)
+ except AttributeError,msg:
+ port_name = "???"
yield port_name, szFriendlyName.value, szHardwareID.value
SetupDiDestroyDeviceInfoList(g_hdi)
@@ -181,9 +184,11 @@ def comports(available_only=True):
if __name__ == '__main__':
import serial
for port, desc, hwid in comports():
- print "%s: %s (%s)" % (port, desc, hwid)
- print " "*10, serial.Serial(port) #test open
-
+ try:
+ print "%s: %s (%s)" % (port, desc, hwid)
+ print " "*10, serial.Serial(port) #test open
+ except serial.serialutil.SerialException:
+ print "can't be openend."
# list of all ports the system knows
print "-"*60
for port, desc, hwid in comports(False):
diff --git a/pyserial/serial/serialutil.py b/pyserial/serial/serialutil.py
index 8bb18b0..fc92fa1 100644
--- a/pyserial/serial/serialutil.py
+++ b/pyserial/serial/serialutil.py
@@ -176,7 +176,7 @@ class SerialBase(FileLike):
# - - - - - - - - - - - - - - - - - - - - - - - -
- # TODO: these are not realy needed as the is the BAUDRATES etc attribute...
+ # TODO: these are not really needed as the is the BAUDRATES etc. attribute...
# maybe i remove them before the final release...
def getSupportedBaudrates(self):