Merge pull request #813 from silsha/fix-gps

Prevent saving gps file without coordinates
This commit is contained in:
Simone Margaritelli 2020-03-31 16:02:44 +02:00 committed by GitHub
commit 8260b41bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,9 +44,15 @@ class GPS(plugins.Plugin):
self.coordinates = info["gps"]
gps_filename = filename.replace(".pcap", ".gps.json")
logging.info(f"saving GPS to {gps_filename} ({self.coordinates})")
with open(gps_filename, "w+t") as fp:
json.dump(self.coordinates, fp)
if self.coordinates and all([
# avoid 0.000... measurements
self.coordinates["Latitude"], self.coordinates["Longitude"]
]):
logging.info(f"saving GPS to {gps_filename} ({self.coordinates})")
with open(gps_filename, "w+t") as fp:
json.dump(self.coordinates, fp)
else:
logging.info("not saving GPS. Couldn't find location.")
def on_ui_setup(self, ui):
# add coordinates for other displays