diff --git a/.gitignore b/.gitignore index 1a5131adc3efc7536ed87ffdbf56f5363b1d8ab2..094a66afd2926b705af8af6c87a4fc7d312f4875 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ *~ *.swp __pycache__ + +/prog/client_config.py diff --git a/dokumentace.md b/dokumentace.md index c70ba034b29bffd30bc5eda30f9964a19ab8866a..c862900b6ab9ea7eb92949ea729d9f5aefb83266 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 0000000000000000000000000000000000000000..ea5276d05df97afba5c53cb090b9c932f559c459 --- /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 a966db35ff7c0e504e1961e317b983ccc04bd886..29d067c581232d6cca3326aa2b6691d277e26661 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()