Sfoglia il codice sorgente

EarwigBot Status page, minor CSS cleanup.

pull/24/head
Ben Kurtovic 13 anni fa
parent
commit
25dc8e1226
3 ha cambiato i file con 69 aggiunte e 3 eliminazioni
  1. +53
    -0
      pages/earwigbot.mako
  2. +13
    -3
      static/css/main.css
  3. +3
    -0
      static/js/potd.js

+ 53
- 0
pages/earwigbot.mako Vedi File

@@ -1,2 +1,55 @@
<%!
from datetime import datetime
import os
import re
from shlex import split
from subprocess import check_output, CalledProcessError, STDOUT

os.environ["SGE_ROOT"] = "/sge62"

def format_date(d):
start = datetime.strptime(d, "%a %b %d %H:%M:%S %Y")
since = start.strftime("%b %d, %Y at %H:%M:%S UTC")
diff = (datetime.utcnow() - start)
if diff.days:
uptime = "{0} days".format(diff.days)
if diff.seconds >= 3600:
uptime += ", {0} hours".format(diff.seconds / 3600)
else:
if diff.seconds > 3600:
uptime = "{0} hours".format(diff.seconds / 3600)
elif diff.seconds > 60:
uptime = "{0} minutes".format(diff.seconds / 60)
else:
uptime = "{0} seconds".format(diff.seconds)
return (since, uptime)

def collect_status_info():
try:
result = check_output(["qstat", "-j", "earwigbot"], stderr=STDOUT)
except CalledProcessError as e:
return ["offline"]

if result.startswith("Following jobs do not exist:"):
return ["offline"]

lines = result.splitlines()[1:]
re_key = "^(.*?):\s"
re_val = ":\s*(.*?)$"
data = dict((re.search(re_key, line).group(1), re.search(re_val, line).group(1)) for line in lines)
since, uptime = format_date(data["submission_time"])
host = data["sge_o_host"]
return ["online", since, uptime, host]
%>\
<%def name="get_status()" filter="trim">
<% status, since, uptime, host = collect_status_info() %>
<span class="${status}">${status}</span>
% if status == "online":
since ${since} (${uptime} uptime) on <tt>${host}</tt>
% endif
</%def>\
<%include file="/support/header.mako" args="environ=environ, title='EarwigBot Status'"/>
<h1>EarwigBot Status</h1>
<p>EarwigBot is ${get_status()}.</p>
<p>Additional information: <a href="http://status.toolserver.org/">status.toolserver.org</a></p>
<%include file="/support/footer.mako" args="environ=environ"/>

+ 13
- 3
static/css/main.css Vedi File

@@ -2,8 +2,8 @@ body {
font-family: helvetica, arial, clean, sans-serif;
font-size: 14px;
color: #000;
/*background-color: #E0E0E0;*/
background-color: #000;
margin: 0;
}

ul, ol {
@@ -11,7 +11,7 @@ ul, ol {
}

div#header {
margin: 20px;
margin: 30px 60px 30px 60px;
padding: 2px 15px 2px 15px;
border: 1px solid #777;
background-color: #FFF;
@@ -19,7 +19,7 @@ div#header {

div#container {
line-height: 1.5;
margin: 0 20px 90px 20px;
margin: 0 60px 100px 60px;
padding: 2px 15px 2px 15px;
border: 1px solid #777;
background-color: #FFF;
@@ -81,6 +81,16 @@ p.tooldesc {
margin: 6px 0 6px 0;
}

span.offline {
color: #900;
font-weight: bold;
}

span.online {
color: #090;
font-weight: bold;
}

span.light { color: #CCC; }
span.medium { color: #AAA; }



+ 3
- 0
static/js/potd.js Vedi File

@@ -65,6 +65,9 @@ function parse_file_url(data, filename) {
if (imgwidth/imgheight > winwidth/winheight) {
width = Math.round((imgwidth/imgheight) * winheight);
}
if (width > imgwidth) {
width = imgwidth;
}
url += "/" + width + "px-" + filename;

document.body.style.backgroundImage="url('" + url + "')";


Caricamento…
Annulla
Salva