From 6b7de75b6236711d7e16d1f6b61f06810e283fcd Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 21 Aug 2015 20:07:19 +0530 Subject: [PATCH] diagnostics: Implement diagnostics for Plinth - Note that while Plinth is running or not running, diagnostics can be run on the command line with --diagnose option to Plinth binary. That makes these tests just as useful as freedombox-setup testsuite. --- plinth/modules/diagnostics/__init__.py | 12 ++++++++++++ plinth/modules/diagnostics/urls.py | 3 +-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plinth/modules/diagnostics/__init__.py b/plinth/modules/diagnostics/__init__.py index 866a9e57c..8005882b3 100644 --- a/plinth/modules/diagnostics/__init__.py +++ b/plinth/modules/diagnostics/__init__.py @@ -21,7 +21,19 @@ Plinth module for system diagnostics from . import diagnostics from .diagnostics import init +from plinth import action_utils __all__ = ['diagnostics', 'init'] depends = ['plinth.modules.system'] + + +def diagnose(): + """Run diagnostics and return the results.""" + results = [] + results.append(action_utils.diagnose_port_listening(8000, 'tcp4')) + results.append(action_utils.diagnose_port_listening(8000, 'tcp6')) + results.extend(action_utils.diagnose_url_on_all( + 'http://{host}/plinth/', extra_options=['--no-check-certificate'])) + + return results diff --git a/plinth/modules/diagnostics/urls.py b/plinth/modules/diagnostics/urls.py index afb7025e5..741538c7c 100644 --- a/plinth/modules/diagnostics/urls.py +++ b/plinth/modules/diagnostics/urls.py @@ -25,7 +25,6 @@ from django.conf.urls import patterns, url urlpatterns = patterns( # pylint: disable-msg=C0103 'plinth.modules.diagnostics.diagnostics', url(r'^sys/diagnostics/$', 'index', name='index'), - url(r'^sys/diagnostics/test/$', 'test', name='test'), - url(r'^sys/diagnostics/module/(?P[a-z\-]+)/$', 'module', + url(r'^sys/diagnostics/(?P[a-z\-]+)/$', 'module', name='module'), )