From 42ead06f659fbe901127ab3d1d6a6f4987d1dbec Mon Sep 17 00:00:00 2001 From: David Huss <dh@atoav.com> Date: Mon, 15 Mar 2021 15:24:26 +0100 Subject: [PATCH] Try life updating id_patterns from server --- stechuhr_client/client.py | 17 +++++++++++++++++ stechuhr_client/config.py | 1 + 2 files changed, 18 insertions(+) diff --git a/stechuhr_client/client.py b/stechuhr_client/client.py index bc10fa5..d0affdd 100644 --- a/stechuhr_client/client.py +++ b/stechuhr_client/client.py @@ -320,6 +320,17 @@ def read_key_input(input_queue, config, logger): time.sleep(0.01) +def update_id_patterns() -> 'Config': + if config["server"]["port"] == 80: + protocol = "http" + else: + protocol = "https" + + url = '{}://{}/config/database/id_patterns'.format(protocol, config["server"]["address"].rstrip("/")) + r = requests.get(url) + print(r.text) + # config["client"]["id_patterns"] + def main(): logging.info('Starting main() in {}'.format(APPLICATION_NAME)) @@ -344,6 +355,8 @@ def main(): # Set the LED to display readyness dispatch_led("startup", config) + last_pattern_update = None + # On the main thread handle communications between the two other threads. That means: # If there is sth. on the input queue, put it onto the output queue if it fits the # specified format @@ -360,6 +373,10 @@ def main(): else: time.sleep(0.01) + if last_pattern_update is None or time.time() - last_pattern_update > config["server"]["update_frequency"]: + last_pattern_update = time.time() + update_id_patterns() + time.sleep(0.01) diff --git a/stechuhr_client/config.py b/stechuhr_client/config.py index 82f3a44..d5a5eb6 100644 --- a/stechuhr_client/config.py +++ b/stechuhr_client/config.py @@ -21,6 +21,7 @@ address = "127.0.0.1" port = 80 timeout = 5 verify_cert = true +update_frequency = 10 [client] location = "lerchenfeld/mensa" -- GitLab