mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] blank lines to make code more readable
This commit is contained in:
parent
642de6dc33
commit
bd28c24479
1 changed files with 26 additions and 0 deletions
|
@ -323,12 +323,15 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False,
|
||||||
# create the pending conf directory for the service
|
# create the pending conf directory for the service
|
||||||
service_pending_path = os.path.join(PENDING_CONF_DIR, name)
|
service_pending_path = os.path.join(PENDING_CONF_DIR, name)
|
||||||
filesystem.mkdir(service_pending_path, 0755, True, uid='admin')
|
filesystem.mkdir(service_pending_path, 0755, True, uid='admin')
|
||||||
|
|
||||||
# return the arguments to pass to the script
|
# return the arguments to pass to the script
|
||||||
return pre_args + [service_pending_path, ]
|
return pre_args + [service_pending_path, ]
|
||||||
|
|
||||||
pre_result = hook_callback('conf_regen', names, pre_callback=_pre_call)
|
pre_result = hook_callback('conf_regen', names, pre_callback=_pre_call)
|
||||||
|
|
||||||
# Update the services name
|
# Update the services name
|
||||||
names = pre_result['succeed'].keys()
|
names = pre_result['succeed'].keys()
|
||||||
|
|
||||||
if not names:
|
if not names:
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError(errno.EIO,
|
||||||
m18n.n('service_regenconf_failed',
|
m18n.n('service_regenconf_failed',
|
||||||
|
@ -386,6 +389,7 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False,
|
||||||
'service_conf_file_manually_removed',
|
'service_conf_file_manually_removed',
|
||||||
conf=system_path))
|
conf=system_path))
|
||||||
conf_status = 'removed'
|
conf_status = 'removed'
|
||||||
|
|
||||||
# -> system conf is not managed yet
|
# -> system conf is not managed yet
|
||||||
elif not saved_hash:
|
elif not saved_hash:
|
||||||
logger.debug("> system conf is not managed yet")
|
logger.debug("> system conf is not managed yet")
|
||||||
|
@ -409,6 +413,7 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False,
|
||||||
logger.warning(m18n.n('service_conf_file_kept_back',
|
logger.warning(m18n.n('service_conf_file_kept_back',
|
||||||
conf=system_path, service=service))
|
conf=system_path, service=service))
|
||||||
conf_status = 'unmanaged'
|
conf_status = 'unmanaged'
|
||||||
|
|
||||||
# -> system conf has not been manually modified
|
# -> system conf has not been manually modified
|
||||||
elif system_hash == saved_hash:
|
elif system_hash == saved_hash:
|
||||||
if to_remove:
|
if to_remove:
|
||||||
|
@ -421,6 +426,7 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False,
|
||||||
logger.debug("> system conf is already up-to-date")
|
logger.debug("> system conf is already up-to-date")
|
||||||
os.remove(pending_path)
|
os.remove(pending_path)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.debug("> system conf has been manually modified")
|
logger.debug("> system conf has been manually modified")
|
||||||
if system_hash == new_hash:
|
if system_hash == new_hash:
|
||||||
|
@ -457,6 +463,7 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False,
|
||||||
'service_conf_updated' if not dry_run else
|
'service_conf_updated' if not dry_run else
|
||||||
'service_conf_would_be_updated',
|
'service_conf_would_be_updated',
|
||||||
service=service))
|
service=service))
|
||||||
|
|
||||||
if succeed_regen and not dry_run:
|
if succeed_regen and not dry_run:
|
||||||
_update_conf_hashes(service, conf_hashes)
|
_update_conf_hashes(service, conf_hashes)
|
||||||
|
|
||||||
|
@ -480,6 +487,7 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False,
|
||||||
else:
|
else:
|
||||||
regen_conf_files = ''
|
regen_conf_files = ''
|
||||||
return post_args + [regen_conf_files, ]
|
return post_args + [regen_conf_files, ]
|
||||||
|
|
||||||
hook_callback('conf_regen', names, pre_callback=_pre_call)
|
hook_callback('conf_regen', names, pre_callback=_pre_call)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -678,25 +686,33 @@ def _get_pending_conf(services=[]):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
if not os.path.isdir(PENDING_CONF_DIR):
|
if not os.path.isdir(PENDING_CONF_DIR):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if not services:
|
if not services:
|
||||||
services = os.listdir(PENDING_CONF_DIR)
|
services = os.listdir(PENDING_CONF_DIR)
|
||||||
|
|
||||||
for name in services:
|
for name in services:
|
||||||
service_pending_path = os.path.join(PENDING_CONF_DIR, name)
|
service_pending_path = os.path.join(PENDING_CONF_DIR, name)
|
||||||
|
|
||||||
if not os.path.isdir(service_pending_path):
|
if not os.path.isdir(service_pending_path):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
path_index = len(service_pending_path)
|
path_index = len(service_pending_path)
|
||||||
service_conf = {}
|
service_conf = {}
|
||||||
|
|
||||||
for root, dirs, files in os.walk(service_pending_path):
|
for root, dirs, files in os.walk(service_pending_path):
|
||||||
for filename in files:
|
for filename in files:
|
||||||
pending_path = os.path.join(root, filename)
|
pending_path = os.path.join(root, filename)
|
||||||
service_conf[pending_path[path_index:]] = pending_path
|
service_conf[pending_path[path_index:]] = pending_path
|
||||||
|
|
||||||
if service_conf:
|
if service_conf:
|
||||||
result[name] = service_conf
|
result[name] = service_conf
|
||||||
else:
|
else:
|
||||||
# remove empty directory
|
# remove empty directory
|
||||||
shutil.rmtree(service_pending_path, ignore_errors=True)
|
shutil.rmtree(service_pending_path, ignore_errors=True)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@ -708,9 +724,11 @@ def _get_conf_hashes(service):
|
||||||
if service not in services:
|
if service not in services:
|
||||||
logger.debug("Service %s is not in services.yml yet.", service)
|
logger.debug("Service %s is not in services.yml yet.", service)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
elif services[service] is None or 'conffiles' not in services[service]:
|
elif services[service] is None or 'conffiles' not in services[service]:
|
||||||
logger.debug("No configuration files for service %s.", service)
|
logger.debug("No configuration files for service %s.", service)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return services[service]['conffiles']
|
return services[service]['conffiles']
|
||||||
|
|
||||||
|
@ -743,11 +761,14 @@ def _process_regen_conf(system_conf, new_conf=None, save=True):
|
||||||
backup_path = os.path.join(BACKUP_CONF_DIR, '{0}-{1}'.format(
|
backup_path = os.path.join(BACKUP_CONF_DIR, '{0}-{1}'.format(
|
||||||
system_conf.lstrip('/'), time.strftime("%Y%m%d.%H%M%S")))
|
system_conf.lstrip('/'), time.strftime("%Y%m%d.%H%M%S")))
|
||||||
backup_dir = os.path.dirname(backup_path)
|
backup_dir = os.path.dirname(backup_path)
|
||||||
|
|
||||||
if not os.path.isdir(backup_dir):
|
if not os.path.isdir(backup_dir):
|
||||||
filesystem.mkdir(backup_dir, 0755, True)
|
filesystem.mkdir(backup_dir, 0755, True)
|
||||||
|
|
||||||
shutil.copy2(system_conf, backup_path)
|
shutil.copy2(system_conf, backup_path)
|
||||||
logger.info(m18n.n('service_conf_file_backed_up',
|
logger.info(m18n.n('service_conf_file_backed_up',
|
||||||
conf=system_conf, backup=backup_path))
|
conf=system_conf, backup=backup_path))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not new_conf:
|
if not new_conf:
|
||||||
os.remove(system_conf)
|
os.remove(system_conf)
|
||||||
|
@ -755,8 +776,10 @@ def _process_regen_conf(system_conf, new_conf=None, save=True):
|
||||||
conf=system_conf))
|
conf=system_conf))
|
||||||
else:
|
else:
|
||||||
system_dir = os.path.dirname(system_conf)
|
system_dir = os.path.dirname(system_conf)
|
||||||
|
|
||||||
if not os.path.isdir(system_dir):
|
if not os.path.isdir(system_dir):
|
||||||
filesystem.mkdir(system_dir, 0755, True)
|
filesystem.mkdir(system_dir, 0755, True)
|
||||||
|
|
||||||
shutil.copyfile(new_conf, system_conf)
|
shutil.copyfile(new_conf, system_conf)
|
||||||
logger.info(m18n.n('service_conf_file_updated',
|
logger.info(m18n.n('service_conf_file_updated',
|
||||||
conf=system_conf))
|
conf=system_conf))
|
||||||
|
@ -766,6 +789,7 @@ def _process_regen_conf(system_conf, new_conf=None, save=True):
|
||||||
conf=system_conf),
|
conf=system_conf),
|
||||||
exc_info=1)
|
exc_info=1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif new_conf:
|
elif new_conf:
|
||||||
try:
|
try:
|
||||||
copy_succeed = os.path.samefile(system_conf, new_conf)
|
copy_succeed = os.path.samefile(system_conf, new_conf)
|
||||||
|
@ -777,8 +801,10 @@ def _process_regen_conf(system_conf, new_conf=None, save=True):
|
||||||
conf=system_conf, new=new_conf),
|
conf=system_conf, new=new_conf),
|
||||||
exc_info=1)
|
exc_info=1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def manually_modified_files():
|
def manually_modified_files():
|
||||||
|
|
||||||
# We do this to have --quiet, i.e. don't throw a whole bunch of logs
|
# We do this to have --quiet, i.e. don't throw a whole bunch of logs
|
||||||
|
|
Loading…
Add table
Reference in a new issue