From 41f1661231f0416877f3fe189eeca4c2b144fb4a Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Tue, 22 Jul 2025 13:52:26 +0300 Subject: [PATCH] Add script for remote log downloading --- tools/log.py | 23 +++++++++++++++++++++++ tools/pyflix/README.md | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 tools/log.py diff --git a/tools/log.py b/tools/log.py new file mode 100755 index 0000000..547f48a --- /dev/null +++ b/tools/log.py @@ -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)}') diff --git a/tools/pyflix/README.md b/tools/pyflix/README.md index 69e2de1..ac06773 100644 --- a/tools/pyflix/README.md +++ b/tools/pyflix/README.md @@ -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