From c51454b7fec3fd4b2ca74ce5b9f5a4f9e148f745 Mon Sep 17 00:00:00 2001 From: kload Date: Wed, 30 Sep 2015 14:17:45 -0400 Subject: [PATCH] [fix] Do not fail when the service is not registered properly --- lib/yunohost/service.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/yunohost/service.py b/lib/yunohost/service.py index cd09cc9d3..000f18ef1 100644 --- a/lib/yunohost/service.py +++ b/lib/yunohost/service.py @@ -199,7 +199,8 @@ def service_status(names=[]): m18n.n('service_unknown', name)) status = None - if services[name]['status'] == 'service': + if 'status' not in services[name] or \ + services[name]['status'] == 'service': status = 'service %s status' % name else: status = str(services[name]['status']) @@ -283,18 +284,11 @@ def service_regenconf(service=None, force=False): """ from yunohost.hook import hook_callback - if service is None: - # Regen ALL THE CONFIGURATIONS - hook_callback('conf_regen', args=[force]) - - msignals.display(m18n.n('services_configured'), 'success') + if service is not None: + hook_callback('conf_regen', [service], args=[force]) else: - if service not in _get_services().keys(): - raise MoulinetteError(errno.EINVAL, m18n.n('service_unknown', service)) - - hook_callback('conf_regen', [service] , args=[force]) - - msignals.display(m18n.n('service_configured', service), 'success') + hook_callback('conf_regen', args=[force]) + msignals.display(m18n.n('services_configured'), 'success') def _run_service_command(action, service): @@ -436,6 +430,7 @@ def service_saferemove(service, conf_file, force=False): """ deleted = False + services = _get_services() if not os.path.exists(conf_file): try: @@ -443,8 +438,6 @@ def service_saferemove(service, conf_file, force=False): except KeyError: pass return True - services = _get_services() - # Backup existing file date = time.strftime("%Y%m%d.%H%M%S") conf_backup_file = conf_backup_dir + conf_file +'-'+ date