summaryrefslogtreecommitdiff
path: root/gpscat
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2016-03-22 03:08:21 -0400
committerEric S. Raymond <esr@thyrsus.com>2016-03-22 03:08:21 -0400
commit8200880a4949fd112674551374868f292b8a6524 (patch)
tree5332fe0413615a729c4953d43cba7a7ea7a1a17f /gpscat
parent254022f6c77e55280c6da59a01ee5225abdf7bcb (diff)
downloadgpsd-8200880a4949fd112674551374868f292b8a6524.tar.gz
Forward-port Python utilities to run polyglot under either Python 2 or 3.
For the moment most shebang lines still say 'python2' rather than just 'python'. This is because the client code in gps/ hasn't been touched yet; the internal imports break under Python 3 and that needs to be fixed.
Diffstat (limited to 'gpscat')
-rwxr-xr-xgpscat16
1 files changed, 9 insertions, 7 deletions
diff --git a/gpscat b/gpscat
index c401397c..17a68052 100755
--- a/gpscat
+++ b/gpscat
@@ -5,6 +5,8 @@
#
# Display GPS output. Hexify it if necessary.
#
+from __future__ import print_function
+
import os, sys, termios, socket, select, getopt, curses.ascii
import gps.packet as sniffer
@@ -42,9 +44,9 @@ if __name__ == '__main__':
try:
try:
(options, arguments) = getopt.getopt(sys.argv[1:], "hps:tD:V")
- except getopt.GetoptError, msg:
- print "gpscat: " + str(msg)
- raise SystemExit, 1
+ except getopt.GetoptError as msg:
+ print("gpscat: " + str(msg))
+ raise SystemExit(1)
speed = None
parity = None
@@ -67,11 +69,11 @@ if __name__ == '__main__':
debuglevel = BASELEVEL + int(val)
elif switch == '-h':
printusage()
- raise SystemExit, 0
+ raise SystemExit(0)
if len(arguments) != 1:
printusage()
- raise SystemExit, 1
+ raise SystemExit(1)
if "rfcomm" in arguments[0]: # Bluetooth special case
s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM)
@@ -86,7 +88,7 @@ if __name__ == '__main__':
ispeed = ospeed = eval("termios.B%d" % speed)
except AttributeError:
sys.stderr.write("gpscat: unknown baud rate %d\n" % speed)
- raise SystemExit, 1
+ raise SystemExit(1)
if stopbits:
cflag &= ~termios.CSIZE
cflag |= (termios.CS8, termios.CS7)[stopbits-1]
@@ -133,7 +135,7 @@ if __name__ == '__main__':
except KeyboardInterrupt:
if rawmode:
sys.stdout.write("\n")
- raise SystemExit, 0
+ raise SystemExit(0)
# Local variables:
# mode: python