diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-03-14 09:17:56 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-03-14 09:17:56 -0400 |
commit | 4ef28bd667515c060015565a9ddf180acf6aedcb (patch) | |
tree | 96202b6588299ce7632acf2ce0ab56422a91a527 /xgps | |
parent | de4764956479dce7151ec5b1460d80f5c1a853e4 (diff) | |
download | gpsd-4ef28bd667515c060015565a9ddf180acf6aedcb.tar.gz |
Make xgps robust against JSON with no time field.
Diffstat (limited to 'xgps')
-rwxr-xr-x | xgps | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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)) |