summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-10-12 10:12:08 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-10-12 10:12:08 +0100
commitb6bcacd137803e0fe2ae568e3bdd066e1f774242 (patch)
tree59fdac72ae4fe194566c15bbc8d2621c6ebc7ebf
parent5e3cc68adbc312df8515f9ec60b5c45e4a9161da (diff)
downloadlorry-controller-b6bcacd137803e0fe2ae568e3bdd066e1f774242.tar.gz
Date/time and sorting
-rw-r--r--lorrycontroller/htmlstatus.py49
1 files changed, 31 insertions, 18 deletions
diff --git a/lorrycontroller/htmlstatus.py b/lorrycontroller/htmlstatus.py
index 50b69ee..04e9489 100644
--- a/lorrycontroller/htmlstatus.py
+++ b/lorrycontroller/htmlstatus.py
@@ -14,6 +14,8 @@ state_names = [
"Finished"
]
+def format_time(time_t):
+ return time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime(time_t))
class HTMLStatusManager(object):
'''Manage the HTML status page for lorry-controller.'''
@@ -77,18 +79,18 @@ class HTMLStatusManager(object):
title = self.tag("title", content="Lorry Controller")
css = self.tag("link", href="trove.css", rel="stylesheet",
type="text/css")
- script = self.tag("script", tyle="text/JavaScript", content='''
+ script = self.tag("script", type="text/JavaScript", content='''
<!--
function reloadAfter(timeout) {
setTimeout("location.reload(true);", timeout);
}
// -->
-''')
+''') + self.tag("script", type="text/javascript", src="/table.js", content="")
return self.tag("head", content=title+css+script)
def gen_body(self):
# 1. Rough header, branded as trove
- curtime = time.asctime(time.gmtime())
+ curtime = format_time(time.time())
link = "/"
if self.series is not None:
link = self.filename + ".%d" % (self.series + 1)
@@ -140,15 +142,15 @@ function reloadAfter(timeout) {
state = "Up to date"
if self.processing == trove['uuid']:
state = "Processing since " + \
- time.asctime(time.gmtime(self.processing_time))
+ format_time(self.processing_time)
elif troveinfo.get('next-vls', now - 1) < now:
if self.state < len(state_names) - 1:
state = "Due to be checked this run."
else:
state = "Due to be checked on the next run"
state = self.tag("td", content=escape(state))
- nextdue = self.tag("td", content=escape(time.asctime(
- time.gmtime(troveinfo.get('next-vls', now - 1)))))
+ nextdue = self.tag("td", content=escape(format_time(
+ troveinfo.get('next-vls', now - 1))))
lorrycount = len([l for l in self.app.conf.lorries.itervalues()
if l['controller-uuid'] == trove['uuid']])
lorrycount = self.tag("td", content=str(lorrycount))
@@ -197,7 +199,7 @@ function reloadAfter(timeout) {
state = "Waiting "
if self.processing == lorry_name:
state = "Processing since " + \
- time.asctime(time.gmtime(self.processing_time))
+ format_time(self.processing_time)
elif lorryinfo.get('next-due', now - 1) < self.bump_time:
if self.state < len(state_names) - 1:
state = "Due to be checked this run."
@@ -214,12 +216,12 @@ function reloadAfter(timeout) {
state = "Dead"
if self.processing == lorry_name:
state = "Removing since " + \
- time.asctime(time.gmtime(self.processing_time))
+ format_time(self.processing_time)
state = self.tag("td", content=escape(state))
lastresult = self.tag("td", content=self.tag(
"pre", content=escape(lorryinfo.get('result', '-'))))
- nextdue = self.tag("td", content=escape(time.asctime(
- time.gmtime(lorryinfo.get('next-due', now - 1)))))
+ nextdue = self.tag("td", content=escape(format_time(
+ lorryinfo.get('next-due', now - 1))))
lorryname = self.tag("td", content=escape(lorry_name))
lorries.append(self.tag("tr", content=
lorryname+uuid+state+lastresult+nextdue))
@@ -227,19 +229,30 @@ function reloadAfter(timeout) {
content = "No lorries detected yet"
else:
header = self.tag("tr", content=
- self.tag("th", content="Lorry Name") +
- self.tag("th", content="Comes From") +
- self.tag("th", content="Status") +
- self.tag("th", content="Last result") +
- self.tag("th", content="Next due"))
- content = self.tag("table", content=
- header + "".join(lorries))
+ self.tag("th",
+ Class="table-sortable:alphanumeric",
+ content="Lorry Name") +
+ self.tag("th",
+ Class="table-sortable:alphanumeric",
+ content="Comes From") +
+ self.tag("th",
+ Class="table-sortable:alphanumeric",
+ content="Status") +
+ self.tag("th",
+ Class="table-sortable:alphanumeric",
+ content="Last result") +
+ self.tag("th",
+ Class="table-sortable:alphanumeric",
+ content="Next due"))
+ header = self.tag("thead", content=header)
+ content = self.tag("table", Class="table-autosort:4", content=
+ header + "\n" + "\n".join(lorries))
return content
def gen_footer(self):
- curtime = time.asctime(time.gmtime())
+ curtime = format_time(time.time())
return self.tag("div", Class="footer", content=
"Generated by Lorry Controller at " + curtime)