From 562edc01f65eb8b84259f9e1c5f03e27269cd024 Mon Sep 17 00:00:00 2001 From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz> Date: Fri, 19 Jul 2024 10:47:46 +0200 Subject: [PATCH] client_config --- .gitignore | 2 ++ dokumentace.md | 2 +- prog/client_config.py.example | 15 +++++++++++++++ prog/main.py | 10 ++++------ 4 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 prog/client_config.py.example diff --git a/.gitignore b/.gitignore index 1a5131a..094a66a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ *~ *.swp __pycache__ + +/prog/client_config.py diff --git a/dokumentace.md b/dokumentace.md index c70ba03..c862900 100644 --- a/dokumentace.md +++ b/dokumentace.md @@ -164,7 +164,7 @@ Pak už stačí jen spustit příslušné servery. V `systemd/init.sh` je script Pro běh klienta je nutné nainstalovat python, QGis (pyqgis), Qt5 (PyQt), python-cbor2, python-qasync, python-matplotlib a zstd. -Dále je nutné mít přístup na server, ten se konfiguruje v `prog/client-config.py` (vzor v `prog/client-config.py.example`). +Dále je nutné mít přístup na server, ten se konfiguruje v `prog/client_config.py` (vzor v `prog/client_config.py.example`). Klient se spouští pomocí `prog/main.py`. diff --git a/prog/client_config.py.example b/prog/client_config.py.example new file mode 100644 index 0000000..ea5276d --- /dev/null +++ b/prog/client_config.py.example @@ -0,0 +1,15 @@ +import communication + +communication.debug = True +# Enable communication debuging + +c = None +async def get_communication(): + # This function must return communication.MainServer connected to your server + # Multiple calls to this function should return the same connection + + global c + cmd='ssh jr@externalArch.jk.dyn.blatto.eu /mnt/jr/jr/prog/run_py server.py' + socket = await communication.SSHRunSocket().connect(cmd) + c = communication.MainServer(socket) + return c diff --git a/prog/main.py b/prog/main.py index a966db3..29d067c 100755 --- a/prog/main.py +++ b/prog/main.py @@ -28,6 +28,9 @@ import gtfs import math +import client_config +from client_config import get_communication + window_title_prefix = "PID realtime" @@ -112,12 +115,7 @@ def no_space(lay): -communications = {} -async def get_communication(cmd='ssh jr@rpi0.jk.dyn.blatto.eu /aux/jr/prog/run_py server.py'): - if cmd not in communications: - s = await communication.SSHRunSocket().connect(cmd) - communications[cmd] = communication.MainServer(s) - return communications[cmd] + async def gtfs_default_data_getter(date, filename): c = await get_communication() -- GitLab