mirror of
https://github.com/unixtensor/proxmox-ntfy.git
synced 2025-06-28 03:48:05 +00:00
print_t.py
module
This commit is contained in:
@ -3,8 +3,9 @@ import time
|
|||||||
import math
|
import math
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from typing import Optional
|
from print_t import print_t
|
||||||
from ntfy import Ntfy
|
from typing import Optional
|
||||||
|
from ntfy import Ntfy
|
||||||
|
|
||||||
_time_now = time.time()
|
_time_now = time.time()
|
||||||
last_cpu_check_warning: float = _time_now
|
last_cpu_check_warning: float = _time_now
|
||||||
@ -35,3 +36,5 @@ class Tempature:
|
|||||||
cpu_temp = math.floor(cpu_temp)
|
cpu_temp = math.floor(cpu_temp)
|
||||||
if cpu_temp >= self.cpu_warning_temp and self.__queue_time(last_cpu_check_warning):
|
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")
|
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")
|
||||||
|
@ -5,8 +5,8 @@ import cli
|
|||||||
import cpu
|
import cpu
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TypedDict
|
from typing import TypedDict
|
||||||
from ntfy import Ntfy
|
from ntfy import Ntfy
|
||||||
|
|
||||||
def start_prompt(server_url: str) -> str:
|
def start_prompt(server_url: str) -> str:
|
||||||
return f"""{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
return f"""{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from datetime import datetime
|
from print_t import print_t
|
||||||
|
|
||||||
def print_t(out: str):
|
|
||||||
t = datetime.now()
|
|
||||||
print(f"({t.strftime('%Y-%m-%d')})[{t.strftime('%H:%M:%S')}]: " + out)
|
|
||||||
|
|
||||||
class Ntfy:
|
class Ntfy:
|
||||||
def __init__(self, server: str):
|
def __init__(self, server: str):
|
||||||
|
5
src/print_t.py
Normal file
5
src/print_t.py
Normal file
@ -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)
|
Reference in New Issue
Block a user