Implament sys.argv with argparse

This commit is contained in:
2025-06-07 00:05:42 -04:00
parent e2dcd795ab
commit 23d0e30ef3
4 changed files with 56 additions and 44 deletions

View File

@ -5,8 +5,11 @@ import re
from typing import Optional
from ntfy import Ntfy
last_cpu_check_unix: float = time.time()
last_cpu_check: int = 60 # Seconds
_time_now = time.time()
last_cpu_check_critical: float = _time_now
last_cpu_check_warning: float = _time_now
last_cpu_check: int = 60 # Seconds
class Tempature:
cpu_temp_crtitical_message: str = "🔥 CPU tempature is at critical tempatures!"
@ -26,10 +29,14 @@ class Tempature:
return float(match.group(1))
return None
def __check_time(self, last_check: float) -> bool:
return (time.time() - last_check) > last_cpu_check * 1000
def ntfy_check(self):
cpu_temp = self.get()
if cpu_temp and (time.time() - last_cpu_check_unix) > last_cpu_check * 1000:
if cpu_temp >= self.cpu_critical_temp:
if cpu_temp:
print(f"{cpu_temp}")
if cpu_temp >= self.cpu_critical_temp and self.__check_time(last_cpu_check_critical):
self.ntfy.send(f"{Tempature.cpu_temp_crtitical_message} {cpu_temp}")
elif cpu_temp >= self.cpu_warning_temp:
if cpu_temp >= self.cpu_warning_temp and self.__check_time(last_cpu_check_warning):
self.ntfy.send(f"{Tempature.cpu_temp_warning_message} {cpu_temp}")