From 5735cd9641e67815496456f9150e506e7f2c04a6 Mon Sep 17 00:00:00 2001 From: rhpidfyre Date: Sat, 7 Jun 2025 16:20:14 -0400 Subject: [PATCH] `print_t.py` module --- src/cpu.py | 7 +++++-- src/main.py | 4 ++-- src/ntfy.py | 6 +----- src/print_t.py | 5 +++++ 4 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 src/print_t.py diff --git a/src/cpu.py b/src/cpu.py index ef7e98a..6e3b587 100644 --- a/src/cpu.py +++ b/src/cpu.py @@ -3,8 +3,9 @@ import time import math import re -from typing import Optional -from ntfy import Ntfy +from print_t import print_t +from typing import Optional +from ntfy import Ntfy _time_now = time.time() last_cpu_check_warning: float = _time_now @@ -35,3 +36,5 @@ class Tempature: cpu_temp = math.floor(cpu_temp) if cpu_temp >= self.cpu_warning_temp and self.__queue_time(last_cpu_check_warning): self.ntfy.send(f"{Tempature.cpu_temp_warning_message} {cpu_temp} C") + else: + print_t("\033[31mCannot get a feasible tempature value for the CPU. (lm-sensors)\033[0m") diff --git a/src/main.py b/src/main.py index ab3cbdc..bfc5c15 100644 --- a/src/main.py +++ b/src/main.py @@ -5,8 +5,8 @@ import cli import cpu from datetime import datetime -from typing import TypedDict -from ntfy import Ntfy +from typing import TypedDict +from ntfy import Ntfy def start_prompt(server_url: str) -> str: return f"""{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} diff --git a/src/ntfy.py b/src/ntfy.py index 7125c1f..b4a7bcc 100644 --- a/src/ntfy.py +++ b/src/ntfy.py @@ -1,10 +1,6 @@ import requests -from datetime import datetime - -def print_t(out: str): - t = datetime.now() - print(f"({t.strftime('%Y-%m-%d')})[{t.strftime('%H:%M:%S')}]: " + out) +from print_t import print_t class Ntfy: def __init__(self, server: str): diff --git a/src/print_t.py b/src/print_t.py new file mode 100644 index 0000000..31ab572 --- /dev/null +++ b/src/print_t.py @@ -0,0 +1,5 @@ +from datetime import datetime + +def print_t(out: str): + t = datetime.now() + print(f"({t.strftime('%Y-%m-%d')})[{t.strftime('%H:%M:%S')}]: " + out) \ No newline at end of file