automatically ignore the service in diagnosis if it has been deactivated with the ynh cli

This commit is contained in:
OniriCorpe 2024-06-29 20:59:41 +02:00
parent cfcbeb3fa9
commit 66f8e31260

View file

@ -26,6 +26,7 @@ from glob import glob
from datetime import datetime from datetime import datetime
from moulinette import m18n from moulinette import m18n
from yunohost.utils.diagnosis import diagnosis_ignore, diagnosis_unignore
from yunohost.utils.error import YunohostError, YunohostValidationError from yunohost.utils.error import YunohostError, YunohostValidationError
from moulinette.utils.process import check_output from moulinette.utils.process import check_output
from moulinette.utils.log import getActionLogger from moulinette.utils.log import getActionLogger
@ -296,6 +297,9 @@ def service_enable(names):
names = [names] names = [names]
for name in names: for name in names:
if _run_service_command("enable", name): if _run_service_command("enable", name):
services = _get_services()
if name in services:
diagnosis_unignore({"services": [{"service": name}]})
logger.success(m18n.n("service_enabled", service=name)) logger.success(m18n.n("service_enabled", service=name))
else: else:
raise YunohostError( raise YunohostError(
@ -315,6 +319,9 @@ def service_disable(names):
names = [names] names = [names]
for name in names: for name in names:
if _run_service_command("disable", name): if _run_service_command("disable", name):
services = _get_services()
if name in services:
diagnosis_ignore({"services": [{"service": name}]})
logger.success(m18n.n("service_disabled", service=name)) logger.success(m18n.n("service_disabled", service=name))
else: else:
raise YunohostError( raise YunohostError(