Convert diagnostics pages to template

This commit is contained in:
Sunil Mohan Adapa 2014-05-08 10:13:38 +05:30
parent eff6306f7d
commit 25fe3c7ee8
3 changed files with 35 additions and 21 deletions

View File

@ -19,7 +19,7 @@
Plinth module for running diagnostics
"""
import os, cherrypy
import cherrypy
from gettext import gettext as _
from auth import require
from plugin_mount import PagePlugin
@ -38,13 +38,8 @@ class diagnostics(PagePlugin):
@cherrypy.expose
@require()
def index(self):
main = _("""
<p>The system diagnostic test will run a number of checks on your
system to confirm that network services are running and configured
properly. It may take a minute to complete.</p>
""")
main += '<p><a class="btn btn-primary btn-large" href="'+cfg.server_dir+'/sys/diagnostics/test">Run diagnostic test &raquo;</a></p>'
return util.render_template(title=_("System Diagnostics"), main=main)
return util.render_template(template='diagnostics',
title=_('System Diagnostics'))
class test(PagePlugin):
order = 31
@ -55,17 +50,8 @@ class test(PagePlugin):
@cherrypy.expose
@require()
def index(self):
main = ''
output, error = actions.superuser_run("diagnostic-test")
if error:
main += _("The diagnostic test encountered an error:</br>")
for line in error.split('\n'):
main += line + "</br>"
if output:
main += _("Output of diagnostic test:</br>")
for line in output.split('\n'):
main += line + "</br>"
return util.render_template(title=_("Diagnostic Test"), main=main)
return util.render_template(template='diagnostics_test',
title=_('Diagnostic Test'),
diagnostics_output=output,
diagnostics_error=error)

View File

@ -0,0 +1,13 @@
{% extends 'login_nav.html' %}
{% block main_block %}
<p>The system diagnostic test will run a number of checks on your
system to confirm that network services are running and configured
properly. It may take a minute to complete.</p>
<p><a class="btn btn-primary btn-large"
href="{{ basehref }}/sys/diagnostics/test">Run diagnostic test
&raquo;</a></p>
{% endblock %}

View File

@ -0,0 +1,15 @@
{% extends 'login_nav.html' %}
{% block main_block %}
{% if diagnostics_error %}
<p>The diagnostic test encountered an error:<p>
<pre>{{ diagnostics_error }}</pre>
{% endif %}
{% if diagnostics_output %}
<p>Output of diagnostic test:</p>
<pre>{{ diagnostics_output }}</pre>
{% endif %}
{% endblock %}