From d85ed1f1130a0174fcca08eedf8c3c48e0441c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Gru=CC=88ndger?= Date: Sat, 8 Dec 2018 09:00:44 +0100 Subject: [PATCH] Fix Flarmnet import --- ogn/commands/database.py | 5 ++++- ogn/utils.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ogn/commands/database.py b/ogn/commands/database.py index 9c06d98..4cb9aab 100644 --- a/ogn/commands/database.py +++ b/ogn/commands/database.py @@ -72,8 +72,9 @@ def import_file(path='tests/custom_ddb.txt'): path=path) print("Imported %i devices." % counter) + @manager.command -def import_flarmnet(path='tests/data.fln'): +def import_flarmnet(path=None): """Import registered devices from a local file.""" print("Import registered devices from '{}'...".format("internet" if path is None else path)) @@ -82,6 +83,7 @@ def import_flarmnet(path='tests/data.fln'): path=path) print("Imported %i devices." % counter) + @manager.command def import_airports(path='tests/SeeYou.cup'): """Import airports from a ".cup" file""" @@ -92,6 +94,7 @@ def import_airports(path='tests/SeeYou.cup'): session.commit() print("Imported {} airports.".format(len(airports))) + @manager.command def update_country_codes(): """Update country codes of all receivers.""" diff --git a/ogn/utils.py b/ogn/utils.py index adc5d6e..f68bb06 100644 --- a/ogn/utils.py +++ b/ogn/utils.py @@ -58,7 +58,7 @@ def get_flarmnet(fln_file=None, address_origin=DeviceInfoOrigin.flarmnet): rows = [bytes.fromhex(line).decode('latin1') for line in r.text.split('\n') if len(line) == 172] else: with open(fln_file, 'r') as file: - rows = [bytes.fromhex(line.strip()).decode('latin1') for line in file.readlines() in len(line) == 172] + rows = [bytes.fromhex(line.strip()).decode('latin1') for line in file.readlines() if len(line) == 172] device_infos = list() for row in rows: