checkIfFirstRunSinceBoot code simplicity

This commit is contained in:
Jarosław Kłopotek - INTERDUO 2024-07-23 09:04:55 +02:00 committed by GitHub
parent dffd5e1a33
commit 0945a09f93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,19 +68,15 @@ def shellReturn(command):
return returnableString return returnableString
def checkIfFirstRunSinceBoot(): 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: with open("lastRun.txt", 'r') as file:
lastRun = datetime.strptime(file.read(), "%d-%b-%Y (%H:%M:%S.%f)") 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.") print("First time run since system boot.")
return True return True
else:
print("Not first time run since system boot.")
return False
else: else:
print("First time run since system boot.") print("Not first time run since system boot.")
return True return False
def clearPriorSettings(interfaceA, interfaceB): def clearPriorSettings(interfaceA, interfaceB):
if enable_actual_shell_commands(): if enable_actual_shell_commands():