From b4c1e0fcaf560ba2a43b7b55de9034ec7b88c7e9 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Fri, 16 Jul 2021 15:29:20 +0200 Subject: [PATCH] Fix parser crash if info key does not exist --- washinsa/washinsa_handler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/washinsa/washinsa_handler.py b/washinsa/washinsa_handler.py index bce1dd4..3b071e7 100644 --- a/washinsa/washinsa_handler.py +++ b/washinsa/washinsa_handler.py @@ -73,13 +73,15 @@ def get_json(code: str, file: TextIO): print("Error reading file " + file.name) print(e) + if not ("info" in file_json): + file_json["info"] = {} + info = file_json["info"] if not ("last_checked" in info) or info[ "last_checked"] < datetime.now().timestamp() * 1000 - CUSTOM_MESSAGE_INTERVAL: print("Updating proxiwash message") info["message"] = get_message(code) info["last_checked"] = datetime.now().timestamp() * 1000 - parsed_data = get_machines(code) file_json["dryers"] = parsed_data["dryers"] file_json["washers"] = parsed_data["washers"]