Thanks for cleaning it up! I had been worried about the higher-level design concerns you'd raised, but moving faster is also good :)
We're using this code live on our vehicles now, so It's getting testing, (at least for our use cases).
In addition, if you're merging it to head, I have some minor additions to suggest:
1. add a missing __init__ call:
diff --git a/gps/gps.py b/gps/gps.py
index 09cf147..765958c 100755
--- a/gps/gps.py
+++ b/gps/gps.py
@@ -171,6 +171,7 @@ class gps(gpscommon, gpsdata, gpsjson):
def __init__(self, host="127.0.0.1", port=GPSD_PORT, verbose=0, mode=0, reconnect=False):
gpscommon.__init__(self, host, port, verbose, reconnect)
gpsdata.__init__(self)
+ gpsjson.__init__(self)
if mode:
self.stream(mode)
2. Better debugging output
===============
Adding the __init__ function doesn't change any function, but it does satisfy a PyCharm warning.
The other line should be self explanatory.
diff --git a/gps/client.py b/gps/client.py
index acb8ce9..c8df122 100644
--- a/gps/client.py
+++ b/gps/client.py
@@ -164,6 +164,10 @@ class json_error(BaseException):
class gpsjson(object):
"Basic JSON decoding."
+
+ def __init__(self):
+ self.stream_command = ""
+
def __iter__(self):
return self
@@ -189,7 +193,7 @@ class gpsjson(object):
sys.stderr.write("send: stream as: {}\n".format(self.stream_command))
self.send(self.stream_command)
else:
- raise TypeError("Could not request a stream: Invalid streaming command!!")
+ raise TypeError("Could not request a stream: Invalid streaming command!! '{}'".format(self.stream_command))