Cleaning up time measurement code.

This commit is contained in:
Marat Fayzullin 2025-01-28 20:03:23 -05:00
parent b2e9886ec5
commit 1c2e63c7f7
2 changed files with 11 additions and 8 deletions

View File

@ -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 += "<div style='color:#00FF00;text-align:center;'>System booted at {0}.</div>\n".format(ts)
ts = ServiceController.renderTime(EIBI.lastStarted())
result += "<div style='color:#00FF00;text-align:center;'>Server started at {0}.</div>\n".format(ts)
ts = ServiceController.lastStarted()
if ts > 0:
ts = ServiceController.renderTime(ts)
result += "<div style='color:#00FF00;text-align:center;'>Server started at {0}.</div>\n".format(ts)
ts = EIBI.lastDownloaded()
if ts > 0:
ts = ServiceController.renderTime(ts)

View File

@ -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():