From 0945a09f93d57684b1c7b9896d6743140d4676f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20K=C5=82opotek=20-=20INTERDUO?= Date: Tue, 23 Jul 2024 09:04:55 +0200 Subject: [PATCH] checkIfFirstRunSinceBoot code simplicity --- src/LibreQoS.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/LibreQoS.py b/src/LibreQoS.py index 260cd2dd..b717792e 100755 --- a/src/LibreQoS.py +++ b/src/LibreQoS.py @@ -68,19 +68,15 @@ def shellReturn(command): return returnableString def checkIfFirstRunSinceBoot(): - if os.path.isfile("lastRun.txt"): + systemRunningSince = datetime.fromtimestamp(psutil.boot_time()) + if !os.path.isfile("lastRun.txt") or systemRunningSince < lastRun: with open("lastRun.txt", 'r') as file: lastRun = datetime.strptime(file.read(), "%d-%b-%Y (%H:%M:%S.%f)") - systemRunningSince = datetime.fromtimestamp(psutil.boot_time()) - if systemRunningSince > lastRun: print("First time run since system boot.") return True - else: - print("Not first time run since system boot.") - return False else: - print("First time run since system boot.") - return True + print("Not first time run since system boot.") + return False def clearPriorSettings(interfaceA, interfaceB): if enable_actual_shell_commands():