From c27a19da56197991e905b338df3c973694923c60 Mon Sep 17 00:00:00 2001 From: Kristian Krsnik Date: Wed, 4 Oct 2023 18:39:47 +0200 Subject: [PATCH] renamed variables --- outage_detector/main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/outage_detector/main.py b/outage_detector/main.py index a0f05ae..145b0b9 100644 --- a/outage_detector/main.py +++ b/outage_detector/main.py @@ -63,11 +63,11 @@ def printOutages(filepath: str, time: int) -> None: last_failed = False # Print the outages. - for outage in outages: + for outage_start, outage_end in [(outage[0], outage[-1]) for outage in outages]: # Get duration of outage in hours and minutes. outage_duration = round( - (outage[-1].date - outage[0].date).seconds / 60 + (outage_end.date - outage_start.date).seconds / 60 ) # Skip printing if outage is shorter than the minimum duration. @@ -77,10 +77,10 @@ def printOutages(filepath: str, time: int) -> None: # Get hours and minutes for printing. hours = outage_duration // 60 minutes = outage_duration - (hours * 60) - host = outage[0].host + host = outage_start.host # Outputs outages in the form of "Outage at: 2023-19-01 06:29:01 lasting for 2 Hours and 39 Minutes". - print(f"[{outage[0].date}][{host}] lasting for {'{} Hours and '.format(hours) if hours >= 1 else ''}{minutes} Minutes") + print(f"[{outage_start.date}][{host}] lasting for {'{} Hours and '.format(hours) if hours >= 1 else ''}{minutes} Minutes") def isOnline(host: str, timeout: int) -> bool: