kopia lustrzana https://github.com/glidernet/ogn-python
Fix Flarmnet import
rodzic
367a6a6bf7
commit
d85ed1f113
|
@ -72,8 +72,9 @@ def import_file(path='tests/custom_ddb.txt'):
|
||||||
path=path)
|
path=path)
|
||||||
print("Imported %i devices." % counter)
|
print("Imported %i devices." % counter)
|
||||||
|
|
||||||
|
|
||||||
@manager.command
|
@manager.command
|
||||||
def import_flarmnet(path='tests/data.fln'):
|
def import_flarmnet(path=None):
|
||||||
"""Import registered devices from a local file."""
|
"""Import registered devices from a local file."""
|
||||||
|
|
||||||
print("Import registered devices from '{}'...".format("internet" if path is None else path))
|
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)
|
path=path)
|
||||||
print("Imported %i devices." % counter)
|
print("Imported %i devices." % counter)
|
||||||
|
|
||||||
|
|
||||||
@manager.command
|
@manager.command
|
||||||
def import_airports(path='tests/SeeYou.cup'):
|
def import_airports(path='tests/SeeYou.cup'):
|
||||||
"""Import airports from a ".cup" file"""
|
"""Import airports from a ".cup" file"""
|
||||||
|
@ -92,6 +94,7 @@ def import_airports(path='tests/SeeYou.cup'):
|
||||||
session.commit()
|
session.commit()
|
||||||
print("Imported {} airports.".format(len(airports)))
|
print("Imported {} airports.".format(len(airports)))
|
||||||
|
|
||||||
|
|
||||||
@manager.command
|
@manager.command
|
||||||
def update_country_codes():
|
def update_country_codes():
|
||||||
"""Update country codes of all receivers."""
|
"""Update country codes of all receivers."""
|
||||||
|
|
|
@ -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]
|
rows = [bytes.fromhex(line).decode('latin1') for line in r.text.split('\n') if len(line) == 172]
|
||||||
else:
|
else:
|
||||||
with open(fln_file, 'r') as file:
|
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()
|
device_infos = list()
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
|
Ładowanie…
Reference in New Issue