From 404db099fdedd43db6e9bdb42da7b8aaaf5c90cd Mon Sep 17 00:00:00 2001 From: Marat Fayzullin Date: Tue, 21 Jan 2025 18:44:59 -0500 Subject: [PATCH] Added uptime display to Settings page. --- owrx/controllers/services.py | 19 ++++++++++++------- owrx/eibi.py | 6 ++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/owrx/controllers/services.py b/owrx/controllers/services.py index 5ddfecc0..7944944d 100644 --- a/owrx/controllers/services.py +++ b/owrx/controllers/services.py @@ -5,6 +5,7 @@ from owrx.service import Services from owrx.repeaters import Repeaters from owrx.eibi import EIBI from datetime import datetime + import json import re @@ -44,18 +45,22 @@ class ServiceController(AuthorizationMixin, WebpageController): @staticmethod def renderStatus(): result = "" - ts = Repeaters.lastDownloaded() - if ts > 0: - ts = datetime.fromtimestamp(ts).strftime("%H:%M:%S, %m/%d/%Y") - result += "
Repeaters database downloaded at {0}.
\n".format(ts) - else: - result += "
Repeaters database not downloaded.
\n" + ts = datetime.fromtimestamp(EIBI.lastStarted()) + td = str(datetime.now() - ts).split(".", 1)[0] + ts = ts.astimezone().strftime("%H:%M:%S %Z, %d %b %Y") + result += "
Server started at {0}, {1} ago.
\n".format(ts, td) ts = EIBI.lastDownloaded() if ts > 0: - ts = datetime.fromtimestamp(ts).strftime("%H:%M:%S, %m/%d/%Y") + ts = datetime.fromtimestamp(ts).astimezone().strftime("%H:%M:%S %Z, %d %b %Y") result += "
Shortwave schedule downloaded at {0}.
\n".format(ts) else: result += "
Shortwave schedule not downloaded.
\n" + ts = Repeaters.lastDownloaded() + if ts > 0: + ts = datetime.fromtimestamp(ts).astimezone().strftime("%H:%M:%S %Z, %d %b %Y") + result += "
Repeaters database downloaded at {0}.
\n".format(ts) + else: + result += "
Repeaters database not downloaded.
\n" return result @staticmethod diff --git a/owrx/eibi.py b/owrx/eibi.py index e4242f68..11dffd7e 100644 --- a/owrx/eibi.py +++ b/owrx/eibi.py @@ -24,6 +24,7 @@ MAX_DISTANCE = 25000 class EIBI(object): sharedInstance = None creationLock = threading.Lock() + timeStarted = time.time() @staticmethod def getSharedInstance(): @@ -37,6 +38,11 @@ class EIBI(object): coreConfig = CoreConfig() return "{data_directory}/eibi.json".format(data_directory=coreConfig.get_data_directory()) + # Get last started timestamp + @staticmethod + def lastStarted(): + return EIBI.timeStarted + # Get last downloaded timestamp or 0 for none @staticmethod def lastDownloaded():