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 import os
from getmac import get_mac_address from getmac import get_mac_address
import time import time
import sys
app = Flask(__name__) app = Flask(__name__)
@ -137,7 +138,8 @@ def start_mqtt_publishers():
except Exception as e: except Exception as e:
print(e) print(e)
except KeyboardInterrupt: except KeyboardInterrupt:
break artNet.close()
sys.exit()
except Exception as e: except Exception as e:
print(e) print(e)

View File

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