Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Warths committed Sep 2, 2021
1 parent 3600341 commit e03517d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
input()
exit(0)


debug = Debugger(
conf.get_value("Debugging", "debug", int),
conf.get_value("Debugging", "log_state_interval", int)
Expand All @@ -34,6 +33,7 @@

error_wait_time = 1


def error(message):
"""
log Error with incremental wait time.
Expand All @@ -46,13 +46,20 @@ def error(message):
sleep(error_wait_time)


def get_debug_message():
return "Game:{sniffer.in_game} " \
"Pause:{sniffer.in_pause} " \
"Tsamples:{sniffer.samples} " \
"RsState:{sniffer.currentState} " \
"LastSwitch:{client.last_scene}".format(sniffer=sniffer, client=client)


# Init debug
debug.log("Debugging starting.")
debug.log("[Behaviour]")
for k, v in conf.content["Behaviour"].items():
debug.log("{} = {}".format(k, v))


# Main loop
while True:
# Sleep and Reload the config.
Expand Down Expand Up @@ -103,6 +110,7 @@ def error(message):
except ConnectionError:
# Restarting the loop and cleaning memory if implicitely failed
import traceback

traceback.print_exc()
sniffer.memory = None
log.notice("Rocksniffer update failed.")
Expand All @@ -113,11 +121,7 @@ def error(message):
continue

# Interval debugging
debug.log_on_interval("Game:{sniffer.in_game} "
"Pause:{sniffer.in_pause} "
"Tsamples:{sniffer.samples} "
"RsState:{sniffer.currentState} "
"LastSwitch:{client.last_scene}".format(sniffer=sniffer, client=client))
debug.log_on_interval(get_debug_message())

# Main Logic
try:
Expand All @@ -135,4 +139,3 @@ def error(message):
except:
log.warning("Error using OBS WebSocket.")
client.socket = None

0 comments on commit e03517d

Please sign in to comment.