From 935bdeb38b09fc6bf3265040b1e3792efeda7163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Sat, 17 Feb 2024 17:34:59 +0100 Subject: [PATCH] FUCK IT. Gonna fix that db spam later MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- server/app.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/server/app.py b/server/app.py index 3c4a5a3..a2a3a90 100644 --- a/server/app.py +++ b/server/app.py @@ -44,12 +44,6 @@ db.autocommit(True) mqtt_client_id = "PiXelTubeMaster-"+wlan_mac_address -cur = db.cursor() -cur.execute("SELECT mac_address, universe, dmx_address FROM tubes") -global TUBE_INDEX -TUBE_INDEX = cur.fetchall() -cur.close() - # Function to register a tube in the database def register_tube(mac_address): cur1 = db.cursor() @@ -115,29 +109,19 @@ def connect_mqtt(): client.connect("localhost", 1883) return client -async def tube_index_updater(): - while True: - cur = db.cursor() - cur.execute("SELECT mac_address, universe, dmx_address FROM tubes") - global TUBE_INDEX - TUBE_INDEX = cur.fetchall() - cur.close() - print("Updated tube index: "+str(TUBE_INDEX)) - time.sleep(1) - if __name__ == "__main__": flask_thread = Process(target=flask_api) flask_thread.start() - index_updater = asyncio.get_event_loop() - asyncio.ensure_future(tube_index_updater()) - index_updater.run_forever() - # Create and start a thread for each universe mqtt_client = connect_mqtt() artnetBindIp = get_eth0_ip() artNet = Artnet.Artnet(BINDIP = artnetBindIp, DEBUG = True, SHORTNAME = "PiXelTubeMaster", LONGNAME = "PiXelTubeMaster", PORT = 6454) while True: + cur = db.cursor() + cur.execute("SELECT mac_address, universe, dmx_address FROM tubes") + TUBE_INDEX = cur.fetchall() + cur.close() try: # Gets whatever the last Art-Net packet we received is artNetPacket = artNet.readPacket()