mirror of
https://github.com/okalachev/flix.git
synced 2025-07-29 12:28:59 +00:00
Add script for remote log downloading
This commit is contained in:
parent
10ab7862a0
commit
41f1661231
23
tools/log.py
Executable file
23
tools/log.py
Executable 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)}')
|
@ -157,7 +157,7 @@ Now you can run `pyflix` scripts and QGroundControl simultaneously.
|
|||||||
The following scripts demonstrate how to use the library:
|
The following scripts demonstrate how to use the library:
|
||||||
|
|
||||||
* [`cli.py`](../cli.py) — remote access to the drone's command line interface.
|
* [`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.
|
* [`example.py`](../example.py) — a simple example, prints telemetry data and waits for events.
|
||||||
|
|
||||||
## Advanced usage
|
## Advanced usage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user