Skip to content

Commit

Permalink
Cleaning up time measurement code.
Browse files Browse the repository at this point in the history
  • Loading branch information
luarvique committed Jan 29, 2025
1 parent b2e9886 commit 1c2e63c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 11 additions & 2 deletions owrx/controllers/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@


class ServiceController(AuthorizationMixin, WebpageController):
timeStarted = time.time()

def indexAction(self):
self.serve_template("services.html", **self.template_variables())

Expand Down Expand Up @@ -44,6 +46,11 @@ def renderServices():
status=ServiceController.renderStatus()
)

# Get last started timestamp
@staticmethod
def lastStarted():
return ServiceController.timeStarted

@staticmethod
def lastBooted():
try:
Expand All @@ -66,8 +73,10 @@ def renderStatus():
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)
Expand Down
6 changes: 0 additions & 6 deletions owrx/eibi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
class EIBI(object):
sharedInstance = None
creationLock = threading.Lock()
timeStarted = time.time()

@staticmethod
def getSharedInstance():
Expand All @@ -38,11 +37,6 @@ def _getCachedScheduleFile():
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():
Expand Down

0 comments on commit 1c2e63c

Please sign in to comment.