testing out json as list conversion

Signed-off-by: Ebbe Baß <ebbe.bass>
main
Ebbe Baß 2024-02-20 15:55:03 +01:00
parent 04288afb7c
commit 9b43808395
1 changed files with 3 additions and 3 deletions

View File

@ -8,7 +8,7 @@ from getmac import get_mac_address
import time import time
from multiprocessing import Process, Pipe, Queue from multiprocessing import Process, Pipe, Queue
from queue import Empty from queue import Empty
from ast import literal_eval import json
app = Flask(__name__) app = Flask(__name__)
@ -132,7 +132,7 @@ def mqtt_publisher(ti_receiver):
print("setting dmxPacket var from artnet data took: "+str(end-start)) print("setting dmxPacket var from artnet data took: "+str(end-start))
if tube_index is not None: if tube_index is not None:
start = time.time() start = time.time()
tube_index = eval(tube_index) tube_index = json.loads(tube_index)
end = time.time() end = time.time()
print("Converting tube index back to list wtih leval took: "+str(end-start)) print("Converting tube index back to list wtih leval took: "+str(end-start))
for index_row in tube_index: for index_row in tube_index:
@ -159,7 +159,7 @@ def tube_index_updater(ti_queue):
cur.execute("SELECT mac_address, universe, dmx_address FROM tubes") cur.execute("SELECT mac_address, universe, dmx_address FROM tubes")
tube_index = cur.fetchall() tube_index = cur.fetchall()
cur.close() cur.close()
ti_queue.put(str(tube_index)) ti_queue.put(json.dumps(tube_index))
except Exception as e: except Exception as e:
print(e) print(e)
time.sleep(5) time.sleep(5)