From e56616af5e7a883824ced4beb5db2d6583c6f638 Mon Sep 17 00:00:00 2001 From: irina11y <38069993+irina11y@users.noreply.github.com> Date: Sun, 2 Sep 2018 18:18:01 +0200 Subject: [PATCH] Allow to add a service description on "yunohost service add" (#529) * [enh] add a service description with YML file * moins "espace" --- data/actionsmap/yunohost.yml | 3 +++ src/yunohost/service.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/data/actionsmap/yunohost.yml b/data/actionsmap/yunohost.yml index 8509bfb23..6e2743015 100644 --- a/data/actionsmap/yunohost.yml +++ b/data/actionsmap/yunohost.yml @@ -1136,6 +1136,9 @@ service: full: --runlevel help: Runlevel priority of the service type: int + -d: + full: --description + help: Description of the service ### service_remove() remove: diff --git a/src/yunohost/service.py b/src/yunohost/service.py index 66ae837a9..dbdaa1cdf 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -50,7 +50,7 @@ MOULINETTE_LOCK = "/var/run/moulinette_yunohost.lock" logger = log.getActionLogger('yunohost.service') -def service_add(name, status=None, log=None, runlevel=None): +def service_add(name, status=None, log=None, runlevel=None, description=None): """ Add a custom service @@ -59,6 +59,7 @@ def service_add(name, status=None, log=None, runlevel=None): status -- Custom status command log -- Absolute path to log file to display runlevel -- Runlevel priority of the service + description -- description of the service """ services = _get_services() @@ -74,6 +75,9 @@ def service_add(name, status=None, log=None, runlevel=None): if runlevel is not None: services[name]['runlevel'] = runlevel + if description is not None: + services[name]['description'] = description + try: _save_services(services) except: @@ -251,7 +255,10 @@ def service_status(names=[]): else: translation_key = "service_description_%s" % name - description = m18n.n(translation_key) + if "description" in services[name] is not None: + description = services[name].get("description") + else: + description = m18n.n(translation_key) # that mean that we don't have a translation for this string # that's the only way to test for that for now