From 1c2e63c7f7c95b4c9bb21253742c6d1a5cf9e901 Mon Sep 17 00:00:00 2001 From: Marat Fayzullin Date: Tue, 28 Jan 2025 20:03:23 -0500 Subject: [PATCH] Cleaning up time measurement code. --- owrx/controllers/services.py | 13 +++++++++++-- owrx/eibi.py | 6 ------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/owrx/controllers/services.py b/owrx/controllers/services.py index 04b631f1..e7070ec6 100644 --- a/owrx/controllers/services.py +++ b/owrx/controllers/services.py @@ -17,6 +17,8 @@ logger = logging.getLogger(__name__) class ServiceController(AuthorizationMixin, WebpageController): + timeStarted = time.time() + def indexAction(self): self.serve_template("services.html", **self.template_variables()) @@ -44,6 +46,11 @@ class ServiceController(AuthorizationMixin, WebpageController): status=ServiceController.renderStatus() ) + # Get last started timestamp + @staticmethod + def lastStarted(): + return ServiceController.timeStarted + @staticmethod def lastBooted(): try: @@ -66,8 +73,10 @@ class ServiceController(AuthorizationMixin, WebpageController): if ts > 0: ts = ServiceController.renderTime(ts) result += "
System booted at {0}.
\n".format(ts) - ts = ServiceController.renderTime(EIBI.lastStarted()) - result += "
Server started at {0}.
\n".format(ts) + ts = ServiceController.lastStarted() + if ts > 0: + ts = ServiceController.renderTime(ts) + result += "
Server started at {0}.
\n".format(ts) ts = EIBI.lastDownloaded() if ts > 0: ts = ServiceController.renderTime(ts) diff --git a/owrx/eibi.py b/owrx/eibi.py index 11dffd7e..e4242f68 100644 --- a/owrx/eibi.py +++ b/owrx/eibi.py @@ -24,7 +24,6 @@ MAX_DISTANCE = 25000 class EIBI(object): sharedInstance = None creationLock = threading.Lock() - timeStarted = time.time() @staticmethod def getSharedInstance(): @@ -38,11 +37,6 @@ 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():