Commit f9853052 authored by Tristan Cavelier's avatar Tristan Cavelier

status.cgi.in +1

parent a56108bf
...@@ -112,7 +112,7 @@ mode = 0644 ...@@ -112,7 +112,7 @@ mode = 0644
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/webfile-directory/${:filename} url = ${:_profile_base_location_}/webfile-directory/${:filename}
download-only = true download-only = true
md5sum = e43d79bec8824265e22df7960744113a md5sum = 61c66c9e2e2da548bb03eee3982d09ed
destination = ${buildout:parts-directory}/monitor-template-status-cgi destination = ${buildout:parts-directory}/monitor-template-status-cgi
filename = status.cgi.in filename = status.cgi.in
mode = 0644 mode = 0644
......
...@@ -18,40 +18,36 @@ json_file = "{{ json_file }}" ...@@ -18,40 +18,36 @@ json_file = "{{ json_file }}"
if not os.path.exists(json_file) or "refresh" in form: if not os.path.exists(json_file) or "refresh" in form:
refresh() refresh()
if not os.path.exists(json_file): result = None
print """<html><head> 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/pure-min.css">
<link rel="stylesheet" href="static/style.css"> <link rel="stylesheet" href="static/style.css">
</head><body> </head><body>
<h1>Monitoring :</h1> <h1>Monitoring:</h1>
No status file found</p></body></html>""" <p>Nothing to monitor</p>
</body></html>""")
exit(0) exit(0)
result = json.load(open(json_file)) print("""<html><head>
<link rel="stylesheet" href="static/pure-min.css">
print "<html><head>" <link rel="stylesheet" href="static/style.css">
print "<link rel=\"stylesheet\" href=\"static/pure-min.css\">" </head><body>
print "<link rel=\"stylesheet\" href=\"static/style.css\">" <h1>Monitoring:</h1>
print "</head><body>" <form action="/index.cgi" method="post" class="pure-form-aligned">
print "<h1>Monitoring :</h1>" <input type="hidden" name="posting-script" value="{{ pwd }}/{{ this_file }}">
print "<form action=\"/index.cgi\" method=\"post\" class=\"pure-form-aligned\">" <p><em>Last time of monitoring process : %(datetime)s</em></p>"
print "<input type=\"hidden\" name=\"posting-script\" value=\"{{ pwd }}/{{ this_file }}\">" <div class="pure-controls">
print "<p><em>Last time of monitoring process : %s</em></p>" % (result['datetime']) <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'] 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("<ul>")
print "<br/>" 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 "<h2>These scripts and promises have failed :</h2>" print("</ul>")
for r in result: print("</body></html>")
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>"
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