From 30e78ee2f03ba48c94c752f887abe63fcb6114d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Mon, 22 Feb 2021 23:58:18 +0100 Subject: [PATCH] forgotten last_status check --- generate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/generate.py b/generate.py index d00720b..7a05ddc 100644 --- a/generate.py +++ b/generate.py @@ -101,7 +101,7 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url: autoescape=select_autoescape(['html', 'xml']) ) - last_state = None + last_status = None while True: logging.info(f"Querying router at {address}...") @@ -150,7 +150,7 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url: ]) db.commit() - if webhook_url: + if webhook_url and last_status != status: requests.post(webhook_url, json={ "text": f"Anabasis is now {status.description}! ({status.text})", "format": "html", @@ -240,6 +240,8 @@ def run_forever(address: str, period: int, ssid: str, output: str, webhook_url: ) file.write(out_str) + last_status = status + logging.info(f"Sleeping for {period} seconds.") sleep(period)