diff options
author | Chris Liechti <cliechti@gmx.net> | 2015-08-21 00:28:53 +0200 |
---|---|---|
committer | Chris Liechti <cliechti@gmx.net> | 2015-08-21 00:28:53 +0200 |
commit | d14b1ab6ecdf39020c7a2f6a1efee1c21254d176 (patch) | |
tree | a0b3e7b49f63b4fd310c02d0042a85a5d11284d6 /serial/urlhandler/protocol_spy.py | |
parent | e9e27ff3da9d9a54f5b6e1f8bd41c6791df01683 (diff) | |
download | pyserial-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.py | 19 |
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]) |