summaryrefslogtreecommitdiff
path: root/xgps
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-03-14 09:17:56 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-03-14 09:17:56 -0400
commit4ef28bd667515c060015565a9ddf180acf6aedcb (patch)
tree96202b6588299ce7632acf2ce0ab56422a91a527 /xgps
parentde4764956479dce7151ec5b1460d80f5c1a853e4 (diff)
downloadgpsd-4ef28bd667515c060015565a9ddf180acf6aedcb.tar.gz
Make xgps robust against JSON with no time field.
Diffstat (limited to 'xgps')
-rwxr-xr-xxgps8
1 files changed, 7 insertions, 1 deletions
diff --git a/xgps b/xgps
index c34bbb8e..78128299 100755
--- a/xgps
+++ b/xgps
@@ -278,7 +278,7 @@ class AISView:
class Base:
gpsfields = (
# First column
- ("Time", lambda s, r: gps.isotime(r.time)),
+ ("Time", lambda s, r: s.update_time(r)),
("Latitude", lambda s, r: s.update_latitude(r)),
("Longitude", lambda s, r: s.update_longitude(r)),
("Altitude", lambda s, r: s.update_altitude(r)),
@@ -462,6 +462,12 @@ class Base:
# State updates
+ def update_time(self, data):
+ if hasattr(data, "time"):
+ return gps.isotime(data.time)
+ else:
+ return "n/a"
+
def update_latitude(self, data):
if data.mode >= gps.MODE_2D:
lat = gps.client.deg_to_str(self.deg_type, abs(data.lat))