From e3c2546b795ba078446873e99527f01dd58e8f4d Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 30 Oct 2023 15:40:30 -0700 Subject: [PATCH] datetime: Fix diagnostic test for checking NTP server sync Fixes: #2384 - This was missed during the original transition to DiagnosticCheck class for returning diagnostic results. Tests: - In vagrant container, test that the diagnostic test result shows up in datetime app and it passes. - Running full diagnostics on the system works. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/datetime/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plinth/modules/datetime/__init__.py b/plinth/modules/datetime/__init__.py index 209154ba4..edee893dd 100644 --- a/plinth/modules/datetime/__init__.py +++ b/plinth/modules/datetime/__init__.py @@ -11,6 +11,7 @@ from plinth import app as app_module from plinth import menu from plinth.daemon import Daemon, RelatedDaemon from plinth.modules.backups.components import BackupRestore +from plinth.modules.diagnostics.check import DiagnosticCheck, Result from plinth.package import Packages from . import manifest @@ -107,13 +108,14 @@ class DateTimeApp(app_module.App): def _diagnose_time_synchronized(): """Check whether time is synchronized to NTP server.""" - result = 'failed' + result = Result.FAILED try: output = subprocess.check_output( ['timedatectl', 'show', '--property=NTPSynchronized', '--value']) if 'yes' in output.decode(): - result = 'passed' + result = Result.PASSED except subprocess.CalledProcessError: pass - return [_('Time synchronized to NTP server'), result] + return DiagnosticCheck('datetime-ntp-sync', + _('Time synchronized to NTP server'), result)