mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Do not fail when the service is not registered properly
This commit is contained in:
parent
17376896a4
commit
c51454b7fe
1 changed files with 7 additions and 14 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue