aboutsummaryrefslogtreecommitdiff
path: root/serial/urlhandler/protocol_spy.py
diff options
context:
space:
mode:
authorChris Liechti <cliechti@gmx.net>2015-08-21 00:28:53 +0200
committerChris Liechti <cliechti@gmx.net>2015-08-21 00:28:53 +0200
commitd14b1ab6ecdf39020c7a2f6a1efee1c21254d176 (patch)
treea0b3e7b49f63b4fd310c02d0042a85a5d11284d6 /serial/urlhandler/protocol_spy.py
parente9e27ff3da9d9a54f5b6e1f8bd41c6791df01683 (diff)
downloadpyserial-d14b1ab6ecdf39020c7a2f6a1efee1c21254d176.tar.gz
URLs: changed paramter delimiter from / to ? and & as it is usual for URLs, update docs
Diffstat (limited to 'serial/urlhandler/protocol_spy.py')
-rw-r--r--serial/urlhandler/protocol_spy.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/serial/urlhandler/protocol_spy.py b/serial/urlhandler/protocol_spy.py
index a4deaef..d6ed458 100644
--- a/serial/urlhandler/protocol_spy.py
+++ b/serial/urlhandler/protocol_spy.py
@@ -165,13 +165,18 @@ class Serial(serial.Serial):
formatter = FormatHexdump
color = False
output = sys.stderr
- for option, values in urlparse.parse_qs(parts.query, True).items():
- if option == 'dev':
- output = open(values[0], 'w')
- elif option == 'color':
- color = True
- elif option == 'raw':
- formatter = FormatRaw
+ try:
+ for option, values in urlparse.parse_qs(parts.query, True).items():
+ if option == 'dev':
+ output = open(values[0], 'w')
+ elif option == 'color':
+ color = True
+ elif option == 'raw':
+ formatter = FormatRaw
+ else:
+ raise ValueError('unknown option: %r' % (option,))
+ except ValueError as e:
+ raise SerialException('expected a string in the form "spy://port[?option[=value][&option[=value]]]": %s' % e)
self.formatter = formatter(output, color)
return ''.join([parts.netloc, parts.path])