added clean exit

Signed-off-by: Ebbe Baß <ebbe.bass>
main
Ebbe Baß 2024-02-15 11:40:55 +01:00
parent e9767daea2
commit 6cd598fc4f
2 changed files with 14 additions and 12 deletions

View File

@ -7,6 +7,7 @@ import python_artnet as Artnet
import os
from getmac import get_mac_address
import time
import sys
app = Flask(__name__)
@ -137,7 +138,8 @@ def start_mqtt_publishers():
except Exception as e:
print(e)
except KeyboardInterrupt:
break
artNet.close()
sys.exit()
except Exception as e:
print(e)

View File

@ -23,18 +23,18 @@ tuple_ip = (str(get_eth0_ip()), 6454)
artNet.art_pol_reply(tuple_ip)
artNetPacket = artNet.readPacket()
print(type(artNetPacket.universe))
# while True:
# try:
# # Gets whatever the last Art-Net packet we received is
# artNetPacket = artNet.readPacket()
# # Make sure we actually *have* a packet
# if artNetPacket is not None and artNetPacket.data is not None:
# print("Universe: "+str(artNetPacket.universe))
# # Stores the packet data array
# dmxPacket = artNetPacket.data
while True:
try:
# Gets whatever the last Art-Net packet we received is
artNetPacket = artNet.readPacket()
# Make sure we actually *have* a packet
if artNetPacket is not None and artNetPacket.data is not None:
print("Universe: "+str(artNetPacket.universe))
# Stores the packet data array
dmxPacket = artNetPacket.data
# except KeyboardInterrupt:
# break
except KeyboardInterrupt:
break
# Close the various connections cleanly so nothing explodes :)
artNet.close()