Added function import_logfile

pull/59/head
dspreitz 2016-09-22 08:40:02 +00:00 zatwierdzone przez Fabian P. Schmidt
rodzic e82ca08288
commit 039f402d64
2 zmienionych plików z 26 dodań i 0 usunięć

Wyświetl plik

@ -104,6 +104,7 @@ available commands:
[gateway]
run Run the aprs client.
import_logfiles Import OGN-data from ogn-log-files <arg: ogn-logfile>.
[logbook]
compute_logbook Compute logbook.

Wyświetl plik

@ -40,3 +40,28 @@ def run(aprs_user='anon-dev', logfile='main.log', loglevel='INFO'):
client.disconnect()
logging.shutdown()
@manager.command
def import_logfile(ogn_logfile, logfile='main.log', loglevel='INFO'):
"""Import OGN-data from ogn-log-files <arg: ogn-logfile>."""
# Check if filename exists
try:
f = open(ogn_logfile, 'r')
except:
print('\nError reading ogn-logfile:', ogn_logfile)
return
# Enable logging
log_handlers = [logging.StreamHandler()]
if logfile:
log_handlers.append(logging.FileHandler(logfile))
logging.basicConfig(format=logging_formatstr, level=loglevel, handlers=log_handlers)
print('Start importing ogn-logfile')
for line in f:
process_beacon(line)
f.close()
logging.shutdown()