diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-11-20 01:43:46 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-11-20 01:43:46 +0000 |
commit | e4cbd2dafe2885a79135e8bb3872a29ca6308e49 (patch) | |
tree | a844d9c52519ad6c074791d94e32b90edd3cffc3 /gpscat | |
parent | b7ba730901b37b6766e5f6a6ee1a14df259cee38 (diff) | |
download | gpsd-e4cbd2dafe2885a79135e8bb3872a29ca6308e49.tar.gz |
Trying to be tricky about which things we hexdumped was a lose.
Addresses Berlios bug #14776: gpsd don't work after python upgrade
from 2.5 to 2.6.
Diffstat (limited to 'gpscat')
-rwxr-xr-x | gpscat | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -11,14 +11,12 @@ NMEA_MAX = 86 # Lowest debug level at which packet getter begins to emit messages, minus one BASELEVEL = gpspacket.LOG_IO +highhalf_latch = True + def hexdump(str): dmp = "" for (i, ch) in enumerate(str): - if curses.ascii.isprint(ord(ch)): - dmp += ch - elif ch == '\r' and i+1 < len(str) and str[i+1] == '\n': - dmp += ch - elif ch == '\n' and i-1 >= 0 and str[i-1] == '\r': + if curses.ascii.isprint(ord(ch)) or curses.ascii.isspace(ord(ch)): dmp += ch else: dmp += "\\x%02x" % ord(ch) @@ -104,9 +102,7 @@ if __name__ == '__main__': if fd == tty and event == select.POLLIN: if rawmode: buf += os.read(tty, NMEA_MAX) - if not buf.endswith("\n"): - buf = hexdump(buf) - sys.stdout.write(buf) + sys.stdout.write(hexdump(buf)) buf = "" else: (length, ptype, packet) = getter.get(tty) |