From 8a01796db940df9b0b2d254e70644e63f487c88c Mon Sep 17 00:00:00 2001 From: oxeo0 Date: Fri, 30 May 2025 16:27:55 +0200 Subject: [PATCH] uptimechecker if statement fix --- scripts/uptimechecker.py | 73 ++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/scripts/uptimechecker.py b/scripts/uptimechecker.py index 0edf637..a27193b 100644 --- a/scripts/uptimechecker.py +++ b/scripts/uptimechecker.py @@ -87,43 +87,42 @@ def main(): index1 = url.find("http://") index2 = url.find("https://") - if url.startswith("smp://") or url.startswith("xftp://"): - if RecognizeURLType(url) == 'smp': - resp,resp_type,failed_response = send_server_checks(url) - - if resp_type in ["chatError", "contactSubSummary"]: - resp, resp_type,failed_response = send_server_checks(url) + urltype = RecognizeURLType(url) + if urltype == 'smp': + resp,resp_type,failed_response = send_server_checks(url) - if failed_response is None: - print(url, "✔️") - df.at[i, "Status"]="YES" - if df.at[i, "Score"] < 100: - df.at[i,"Score"] = df.at[i,"Score"] + 1 - else: - print(url,"❌") - df.at[i,"Status"]="NO" - #if uptime >0 do -1 to the value - if df.at[i,"Score"] > 0: - df.at[i,"Score"] = df.at[i,"Score"] - 1 - - elif RecognizeURLType(url) == 'xftp': - resp,resp_type,failed_response = send_server_checks(url) - - if resp_type in ["chatError", "contactSubSummary"]: - resp, resp_type,failed_response = send_server_checks(url) - - if failed_response is None: - print(url, "✔️") - df.at[i, "Status"]="YES" - if df.at[i, "Score"] < 100: - df.at[i,"Score"] = df.at[i,"Score"] + 1 - else: - print(url,"❌") - df.at[i,"Status"]="NO" - #if uptime >0 do -1 to the value - if df.at[i,"Score"] > 0: - df.at[i,"Score"] = df.at[i,"Score"] - 1 + if resp_type in ["chatError", "contactSubSummary"]: + resp, resp_type,failed_response = send_server_checks(url) + + if failed_response is None: + print(url, "✔️") + df.at[i, "Status"]="YES" + if df.at[i, "Score"] < 100: + df.at[i,"Score"] = df.at[i,"Score"] + 1 + else: + print(url,"❌") + df.at[i,"Status"]="NO" + #if uptime >0 do -1 to the value + if df.at[i,"Score"] > 0: + df.at[i,"Score"] = df.at[i,"Score"] - 1 + elif urltype == 'xftp': + resp,resp_type,failed_response = send_server_checks(url) + + if resp_type in ["chatError", "contactSubSummary"]: + resp, resp_type,failed_response = send_server_checks(url) + + if failed_response is None: + print(url, "✔️") + df.at[i, "Status"]="YES" + if df.at[i, "Score"] < 100: + df.at[i,"Score"] = df.at[i,"Score"] + 1 + else: + print(url,"❌") + df.at[i,"Status"]="NO" + #if uptime >0 do -1 to the value + if df.at[i,"Score"] > 0: + df.at[i,"Score"] = df.at[i,"Score"] - 1 else: if index1 == -1 and index2 == -1: @@ -144,14 +143,14 @@ def main(): if df.at[i,"Score"] > 0: df.at[i,"Score"] = df.at[i,"Score"] - 1 - except requests.ConnectionError as e: + except requests.ConnectionError: #print(e) print(url,"❌") df.at[i,"Status"]="NO" #if uptime >0 do -1 to the value if df.at[i,"Score"] > 0: df.at[i,"Score"] = df.at[i,"Score"] - 1 - except requests.exceptions.ReadTimeout as e: + except requests.exceptions.ReadTimeout: #print(e) print(url,"❌") df.at[i,"Status"]="NO"