Added system-booted display to the Settings page.

This commit is contained in:
Marat Fayzullin 2025-01-25 22:52:08 -05:00
parent bc12058ce5
commit b2e9886ec5
1 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,8 @@ from owrx.eibi import EIBI
from datetime import datetime from datetime import datetime
import json import json
import time
import os
import re import re
import logging import logging
@ -42,6 +44,14 @@ class ServiceController(AuthorizationMixin, WebpageController):
status=ServiceController.renderStatus() status=ServiceController.renderStatus()
) )
@staticmethod
def lastBooted():
try:
with open('/proc/uptime', 'r') as f:
return time.time() - float(f.readline().split()[0])
except:
return 0
@staticmethod @staticmethod
def renderTime(ts): def renderTime(ts):
ts = datetime.fromtimestamp(ts) ts = datetime.fromtimestamp(ts)
@ -52,6 +62,10 @@ class ServiceController(AuthorizationMixin, WebpageController):
@staticmethod @staticmethod
def renderStatus(): def renderStatus():
result = "" result = ""
ts = ServiceController.lastBooted()
if ts > 0:
ts = ServiceController.renderTime(ts)
result += "<div style='color:#00FF00;text-align:center;'>System booted at {0}.</div>\n".format(ts)
ts = ServiceController.renderTime(EIBI.lastStarted()) ts = ServiceController.renderTime(EIBI.lastStarted())
result += "<div style='color:#00FF00;text-align:center;'>Server started at {0}.</div>\n".format(ts) result += "<div style='color:#00FF00;text-align:center;'>Server started at {0}.</div>\n".format(ts)
ts = EIBI.lastDownloaded() ts = EIBI.lastDownloaded()