From 798133f124d26eff125273d26c172d8a04afd9e7 Mon Sep 17 00:00:00 2001 From: jowj Date: Sun, 2 Dec 2018 21:44:27 -0600 Subject: [PATCH] Track state in a different file to allow for consistent tracking. --- arke.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arke.py b/arke.py index 01ca02c..4cab95e 100644 --- a/arke.py +++ b/arke.py @@ -24,7 +24,9 @@ while is_on: # track state file = open("/shared/results.json", "r") - oldData = file.read() + stateFile = open("/shared/state.log", "r") + + oldData = stateFile.read() if oldData != json_string: stateChanged = True else: @@ -32,7 +34,8 @@ while is_on: # old file removal must happen after state tracking: os.remove("/shared/results.json") - + os.remove("/shared/state.log") + # write new results to file file = open("/shared/results.json", "a+") file.write(json_string) @@ -45,6 +48,12 @@ while is_on: results.append(json.loads(line)) for key,value in results[-1].items(): + # track state + errorFile = open("/shared/state.log", "w") + errorText = key + " returned with status " + str(value) + "\n" + errorFile.write(errorText) + errorFile.close() + if stateChanged == True: errorFile = open("/shared/alerts.log", "w") errorText = key + " returned with status " + str(value) + "\n"