From 9aa44f1292b15049e81c647febe1cf0b5e1f8dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Sat, 17 Feb 2024 01:02:05 +0100 Subject: [PATCH] added fail safe if pxm isn't reacheable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- client/main.py | 2 ++ server/app.py | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/client/main.py b/client/main.py index 4b614a2..bfc5a46 100644 --- a/client/main.py +++ b/client/main.py @@ -8,6 +8,7 @@ from threading import Thread import paho.mqtt.client as mqtt from getmac import get_mac_address import board +import sys SERVER_IP = '192.168.0.1' SERVER_PORT = 5000 @@ -101,6 +102,7 @@ def loopCheckSettingUpdates(): print(universe, dmx_address) except Exception as e: print(f"Error: {e}") + sys.exit() time.sleep(2) if __name__ == "__main__": diff --git a/server/app.py b/server/app.py index 68eae09..7b077c9 100644 --- a/server/app.py +++ b/server/app.py @@ -52,13 +52,12 @@ def register_tube(mac_address): print(existing_tube) - if existing_tube is not None: - # Tube already exists, do nothing for now - pass - else: - # Tube is new, insert into the database + # Check if the tube exsist. If it doesn't create a new db row + if existing_tube is None: cur.execute("INSERT INTO tubes (mac_address, universe, dmx_address) VALUES (%s, %s, %s)", - (mac_address, 0, 1)) # Universe 0, DMX Address 1 + (mac_address, 0, 1)) + else: + pass cur.close() # Registration system route