Add script for remote log downloading

This commit is contained in:
Oleg Kalachev 2025-07-22 13:52:26 +03:00
parent 10ab7862a0
commit 41f1661231
2 changed files with 24 additions and 1 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)}')

View File

@ -157,7 +157,7 @@ Now you can run `pyflix` scripts and QGroundControl simultaneously.
The following scripts demonstrate how to use the library:
* [`cli.py`](../cli.py) — remote access to the drone's command line interface.
* `log.py` — download flight logs from the drone.
* [`log.py`](../log.py) — download flight logs from the drone.
* [`example.py`](../example.py) — a simple example, prints telemetry data and waits for events.
## Advanced usage