From f9c9c628370f8e8d1c62995579c85f00af135621 Mon Sep 17 00:00:00 2001 From: Alice Kile Date: Fri, 22 Nov 2019 12:02:06 +0530 Subject: [PATCH] diagnostics: don't run on disabled modules Reviewed-by: Joseph Nuthalapati --- plinth/modules/diagnostics/diagnostics.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plinth/modules/diagnostics/diagnostics.py b/plinth/modules/diagnostics/diagnostics.py index c5480933b..9cf36ca49 100644 --- a/plinth/modules/diagnostics/diagnostics.py +++ b/plinth/modules/diagnostics/diagnostics.py @@ -78,14 +78,15 @@ def _start_task(): if _running_task: raise Exception('Task already running') - _running_task = threading.Thread(target=_run_on_all_modules_wrapper) + _running_task = threading.Thread( + target=_run_on_all_enabled_modules_wrapper) _running_task.start() -def _run_on_all_modules_wrapper(): +def _run_on_all_enabled_modules_wrapper(): """Wrapper over actual task to catch exceptions.""" try: - run_on_all_modules() + run_on_all_enabled_modules() except Exception as exception: logger.exception('Error running diagnostics - %s', exception) current_results['error'] = str(exception) @@ -94,8 +95,8 @@ def _run_on_all_modules_wrapper(): _running_task = None -def run_on_all_modules(): - """Run diagnostics on all modules and store the result.""" +def run_on_all_enabled_modules(): + """Run diagnostics on all the enabled modules and store the result.""" global current_results current_results = { 'modules': [], @@ -113,6 +114,9 @@ def run_on_all_modules(): if module.setup_helper.get_state() == 'needs-setup': continue + if not module.app.is_enabled(): + continue + modules.append((module_name, module)) current_results['results'][module_name] = None