Commit f9853052 authored by Tristan Cavelier's avatar Tristan Cavelier

status.cgi.in +1

parent a56108bf
......@@ -112,7 +112,7 @@ mode = 0644
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfile-directory/${:filename}
download-only = true
md5sum = e43d79bec8824265e22df7960744113a
md5sum = 61c66c9e2e2da548bb03eee3982d09ed
destination = ${buildout:parts-directory}/monitor-template-status-cgi
filename = status.cgi.in
mode = 0644
......
......@@ -18,40 +18,36 @@ json_file = "{{ json_file }}"
if not os.path.exists(json_file) or "refresh" in form:
refresh()
if not os.path.exists(json_file):
print """<html><head>
result = None
if os.path.exists(json_file):
result = json.load(open(json_file))
if result is None or not result.keys():
print("""<html><head>
<link rel="stylesheet" href="static/pure-min.css">
<link rel="stylesheet" href="static/style.css">
</head><body>
<h1>Monitoring :</h1>
No status file found</p></body></html>"""
<h1>Monitoring:</h1>
<p>Nothing to monitor</p>
</body></html>""")
exit(0)
result = json.load(open(json_file))
print "<html><head>"
print "<link rel=\"stylesheet\" href=\"static/pure-min.css\">"
print "<link rel=\"stylesheet\" href=\"static/style.css\">"
print "</head><body>"
print "<h1>Monitoring :</h1>"
print "<form action=\"/index.cgi\" method=\"post\" class=\"pure-form-aligned\">"
print "<input type=\"hidden\" name=\"posting-script\" value=\"{{ pwd }}/{{ this_file }}\">"
print "<p><em>Last time of monitoring process : %s</em></p>" % (result['datetime'])
print("""<html><head>
<link rel="stylesheet" href="static/pure-min.css">
<link rel="stylesheet" href="static/style.css">
</head><body>
<h1>Monitoring:</h1>
<form action="/index.cgi" method="post" class="pure-form-aligned">
<input type="hidden" name="posting-script" value="{{ pwd }}/{{ this_file }}">
<p><em>Last time of monitoring process : %(datetime)s</em></p>"
<div class="pure-controls">
<button type="submit" class="pure-button pure-button-primary" name="refresh" value="refresh">Refresh</button>
</div>
</form><br/>""" % {"datetime": cgi.escape(result['datetime'])})
del result['datetime']
print "<div class=\"pure-controls\"><button type=\"submit\" class=\"pure-button \
pure-button-primary\" name=\"refresh\" value=\"refresh\">Refresh</button></div></form>"
print "<br/>"
print "<h2>These scripts and promises have failed :</h2>"
for r in result:
if result[r] != '':
print "<h3>%s</h3><pre style=\"padding-left:30px;\">%s</pre>" % (cgi.escape(r), cgi.escape(result[r]))
print "<br/>"
print "<h2>These scripts and promises were successful :</h2>"
print "<ul>"
for r in result:
if result[r] == '':
print "<li>%s</li>" % (r)
print "</ul>"
print "</body></html>"
print("<ul>")
for title in result:
print("<li><span>%(title)s</span><span>%(color)s</span>" % {"title": cgi.escape(title), "color": "red" if result[title] else "green"} )
print("</ul>")
print("</body></html>")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment