Add Python library (#20)

This commit is contained in:
Oleg Kalachev
2025-07-22 14:17:08 +03:00
committed by GitHub
parent 779fa13e80
commit 1f47aa6d62
12 changed files with 713 additions and 2 deletions

23
tools/log.py Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# Download flight log remotely and save to file
import os
import datetime
from pyflix import Flix
DIR = os.path.dirname(os.path.realpath(__file__))
flix = Flix()
print('Downloading log...')
lines = flix.cli('log').splitlines()
# sort by timestamp
header = lines.pop(0)
lines.sort(key=lambda line: float(line.split(',')[0]))
log = open(f'{DIR}/log/{datetime.datetime.now().isoformat()}.csv', 'wb')
content = header.encode() + b'\n' + b'\n'.join(line.encode() for line in lines)
log.write(content)
print(f'Written {os.path.relpath(log.name, os.curdir)}')