Cleaning up time measurement code.
This commit is contained in:
parent
b2e9886ec5
commit
1c2e63c7f7
|
|
@ -17,6 +17,8 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class ServiceController(AuthorizationMixin, WebpageController):
|
class ServiceController(AuthorizationMixin, WebpageController):
|
||||||
|
timeStarted = time.time()
|
||||||
|
|
||||||
def indexAction(self):
|
def indexAction(self):
|
||||||
self.serve_template("services.html", **self.template_variables())
|
self.serve_template("services.html", **self.template_variables())
|
||||||
|
|
||||||
|
|
@ -44,6 +46,11 @@ class ServiceController(AuthorizationMixin, WebpageController):
|
||||||
status=ServiceController.renderStatus()
|
status=ServiceController.renderStatus()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Get last started timestamp
|
||||||
|
@staticmethod
|
||||||
|
def lastStarted():
|
||||||
|
return ServiceController.timeStarted
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def lastBooted():
|
def lastBooted():
|
||||||
try:
|
try:
|
||||||
|
|
@ -66,8 +73,10 @@ class ServiceController(AuthorizationMixin, WebpageController):
|
||||||
if ts > 0:
|
if ts > 0:
|
||||||
ts = ServiceController.renderTime(ts)
|
ts = ServiceController.renderTime(ts)
|
||||||
result += "<div style='color:#00FF00;text-align:center;'>System booted at {0}.</div>\n".format(ts)
|
result += "<div style='color:#00FF00;text-align:center;'>System booted at {0}.</div>\n".format(ts)
|
||||||
ts = ServiceController.renderTime(EIBI.lastStarted())
|
ts = ServiceController.lastStarted()
|
||||||
result += "<div style='color:#00FF00;text-align:center;'>Server started at {0}.</div>\n".format(ts)
|
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()
|
ts = EIBI.lastDownloaded()
|
||||||
if ts > 0:
|
if ts > 0:
|
||||||
ts = ServiceController.renderTime(ts)
|
ts = ServiceController.renderTime(ts)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ MAX_DISTANCE = 25000
|
||||||
class EIBI(object):
|
class EIBI(object):
|
||||||
sharedInstance = None
|
sharedInstance = None
|
||||||
creationLock = threading.Lock()
|
creationLock = threading.Lock()
|
||||||
timeStarted = time.time()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getSharedInstance():
|
def getSharedInstance():
|
||||||
|
|
@ -38,11 +37,6 @@ class EIBI(object):
|
||||||
coreConfig = CoreConfig()
|
coreConfig = CoreConfig()
|
||||||
return "{data_directory}/eibi.json".format(data_directory=coreConfig.get_data_directory())
|
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
|
# Get last downloaded timestamp or 0 for none
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def lastDownloaded():
|
def lastDownloaded():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue