From c349d875a619dc11793aada44b4470a6c336ece7 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Mon, 24 Mar 2014 20:17:28 -0400 Subject: [PATCH 1/2] Add diagnostic test which runs the freedombox testsuite and displays its result. --- actions/diagnostic-test | 3 ++ modules/diagnostics.py | 1 + modules/installed/system/diagnostics.py | 48 +++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100755 actions/diagnostic-test create mode 120000 modules/diagnostics.py create mode 100644 modules/installed/system/diagnostics.py diff --git a/actions/diagnostic-test b/actions/diagnostic-test new file mode 100755 index 000000000..10f8610d5 --- /dev/null +++ b/actions/diagnostic-test @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/lib/freedombox/testsuite/check diff --git a/modules/diagnostics.py b/modules/diagnostics.py new file mode 120000 index 000000000..31b7abf86 --- /dev/null +++ b/modules/diagnostics.py @@ -0,0 +1 @@ +installed/system/diagnostics.py \ No newline at end of file diff --git a/modules/installed/system/diagnostics.py b/modules/installed/system/diagnostics.py new file mode 100644 index 000000000..50bce40e3 --- /dev/null +++ b/modules/installed/system/diagnostics.py @@ -0,0 +1,48 @@ +import os, cherrypy +from gettext import gettext as _ +from auth import require +from plugin_mount import PagePlugin +import actions +import cfg + +class diagnostics(PagePlugin): + order = 30 + def __init__(self, *args, **kwargs): + PagePlugin.__init__(self, *args, **kwargs) + self.register_page("sys.diagnostics") + cfg.html_root.sys.menu.add_item("Diagnostics", "icon-screenshot", "/sys/diagnostics", 30) + + @cherrypy.expose + @require() + def index(self): + main = _(""" +

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.

+ """) + main += '

Run diagnostic test »

' + return self.fill_template(title=_("System Diagnostics"), main=main) + +class test(PagePlugin): + order = 31 + def __init__(self, *args, **kwargs): + PagePlugin.__init__(self, *args, **kwargs) + self.register_page("sys.diagnostics.test") + + @cherrypy.expose + @require() + def index(self): + main = '' + output, error = actions.superuser_run("diagnostic-test") + + if error: + main += _("The diagnostic test encountered an error:
") + for line in error.split('\n'): + main += line + "
" + + if output: + main += _("Output of diagnostic test:
") + for line in output.split('\n'): + main += line + "
" + + return self.fill_template(title=_("Diagnostic Test"), main=main) From 67a5280073aa709fb53021c3b7e11f783fe234cf Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Mon, 24 Mar 2014 20:46:51 -0400 Subject: [PATCH 2/2] Add license information and description for diagnostics module. --- LICENSES | 1 + modules/installed/system/diagnostics.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/LICENSES b/LICENSES index 09717ea6d..6032b44ea 100644 --- a/LICENSES +++ b/LICENSES @@ -62,6 +62,7 @@ specified and linked otherwise. - modules/installed/sharing/file_explorer.py :: - - modules/installed/sharing/sharing.py :: - - modules/installed/system/config.py :: - +- modules/installed/system/diagnostics.py :: - - modules/installed/system/expert_mode.py :: - - modules/installed/system/system.py :: - - modules/installed/system/time_zones :: - diff --git a/modules/installed/system/diagnostics.py b/modules/installed/system/diagnostics.py index 50bce40e3..b87afb68d 100644 --- a/modules/installed/system/diagnostics.py +++ b/modules/installed/system/diagnostics.py @@ -1,3 +1,24 @@ +# +# This file is part of Plinth. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +""" +Plinth module for running diagnostics +""" + import os, cherrypy from gettext import gettext as _ from auth import require