From cb3e050722939216707b6c01daa95b8dd8dcdebd Mon Sep 17 00:00:00 2001 From: Matthias Dellweg <2500@gmx.de> Date: Sun, 22 Sep 2019 10:40:24 +0000 Subject: [PATCH] diagnose: Move negating diagnose result inside try bock A caught Exception should always be considered a failed test. Signed-off-by: Matthias Dellweg <2500@gmx.de> Reviewed-by: Sunil Mohan Adapa --- plinth/action_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plinth/action_utils.py b/plinth/action_utils.py index 67ab7728c..353fb7423 100644 --- a/plinth/action_utils.py +++ b/plinth/action_utils.py @@ -423,12 +423,14 @@ def diagnose_netcat(host, port, input='', negate=False): result = 'failed' else: result = 'passed' + + if negate: + result = 'failed' if result == 'passed' else 'passed' except Exception: result = 'failed' test = _('Connect to {host}:{port}') if negate: - result = 'failed' if result == 'passed' else 'passed' test = _('Cannot connect to {host}:{port}') return [test.format(host=host, port=port), result]