summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel_M_Williams <equipoise@gmail.com>2018-05-21 17:35:05 -0700
committerGary E. Miller <gem@rellim.com>2018-05-21 17:35:05 -0700
commit0149f55bc22cdcbe6f662fab2563479170adc653 (patch)
treea02690e34a8da8b3adb7d6d19971138f25086868
parent30c91060282277836848898103fb7bd0db047500 (diff)
downloadgpsd-0149f55bc22cdcbe6f662fab2563479170adc653.tar.gz
[PATCH] [fix] gps/*py now passes `scons check`
Whoops, the auto reconnect patch broke scons check. Signed-off-by: Gary E. Miller <gem@rellim.com>
-rw-r--r--gps/client.py24
-rwxr-xr-xgps/gps.py1
2 files changed, 19 insertions, 6 deletions
diff --git a/gps/client.py b/gps/client.py
index 2f1b5201..b3f4946e 100644
--- a/gps/client.py
+++ b/gps/client.py
@@ -32,6 +32,7 @@ class gpscommon(object):
self.host = host
if port is not None:
self.port = port
+ self.connect(self.host, self.port)
def connect(self, host, port):
"""Connect to a host on a given port.
@@ -86,6 +87,9 @@ class gpscommon(object):
"Return True if data is ready for the client."
if self.linebuffer:
return True
+ if self.sock is None:
+ return False
+
(winput, _woutput, _wexceptions) = select.select(
(self.sock,), (), (), timeout)
return winput != []
@@ -152,7 +156,10 @@ class gpscommon(object):
"Ship commands to the daemon."
if not commands.endswith("\n"):
commands += "\n"
- if None is not self.sock:
+
+ if self.sock is None:
+ self.stream_command = commands
+ else:
self.sock.send(polybytes(commands))
@@ -166,6 +173,11 @@ class json_error(BaseException):
class gpsjson(object):
"Basic JSON decoding."
+ def __init__(self):
+ self.stream_command = None
+ self.data = None
+ self.verbose = -1
+
def __iter__(self):
return self
@@ -185,15 +197,15 @@ class gpsjson(object):
if 0 < flags:
self.stream_command = self.generate_stream_command(flags, devpath)
+ else:
+ self.steam_command = self.enqueued
if self.stream_command:
- if self.verbose > 1:
- sys.stderr.write(
- "send: stream as: {}\n".format(self.stream_command))
+ # if self.verbose > 1:
+ 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("Invalid streaming command!! : "+str(flags))
def generate_stream_command(self, flags=0, devpath=None):
if flags & WATCH_OLDSTYLE:
diff --git a/gps/gps.py b/gps/gps.py
index c5d69129..99b33366 100755
--- a/gps/gps.py
+++ b/gps/gps.py
@@ -173,6 +173,7 @@ class gps(gpscommon, gpsdata, gpsjson):
reconnect=False):
gpscommon.__init__(self, host, port, verbose, reconnect)
gpsdata.__init__(self)
+ gpsjson.__init__(self)
if mode:
self.stream(mode)