mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Add succeed hooks to the backup archive info
This commit is contained in:
parent
4c37d8f273
commit
cf0af877d9
2 changed files with 13 additions and 8 deletions
|
@ -116,17 +116,21 @@ def backup_create(name=None, description=None, output_directory=None,
|
||||||
else:
|
else:
|
||||||
os.system('chown -hR admin: %s' % tmp_dir)
|
os.system('chown -hR admin: %s' % tmp_dir)
|
||||||
|
|
||||||
# Run system hooks
|
|
||||||
msignals.display(m18n.n('backup_running_hooks'))
|
|
||||||
hook_callback('backup', hooks, args=[tmp_dir])
|
|
||||||
|
|
||||||
# Initialize backup info
|
# Initialize backup info
|
||||||
info = {
|
info = {
|
||||||
'description': description or '',
|
'description': description or '',
|
||||||
'created_at': timestamp,
|
'created_at': timestamp,
|
||||||
'apps': {},
|
'apps': {},
|
||||||
|
'hooks': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run system hooks
|
||||||
|
msignals.display(m18n.n('backup_running_hooks'))
|
||||||
|
hooks_ret = hook_callback('backup', hooks, args=[tmp_dir])
|
||||||
|
|
||||||
|
# Add hooks results to the info
|
||||||
|
info['hooks'] = hooks_ret['succeed']
|
||||||
|
|
||||||
# Backup apps
|
# Backup apps
|
||||||
if not ignore_apps:
|
if not ignore_apps:
|
||||||
from yunohost.app import app_info
|
from yunohost.app import app_info
|
||||||
|
@ -377,4 +381,5 @@ def backup_info(name):
|
||||||
time.gmtime(info['created_at'])),
|
time.gmtime(info['created_at'])),
|
||||||
'description': info['description'],
|
'description': info['description'],
|
||||||
'apps': info['apps'],
|
'apps': info['apps'],
|
||||||
|
'hooks': info['hooks'],
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ def hook_callback(action, hooks=[], args=None):
|
||||||
args -- Ordered list of arguments to pass to the script
|
args -- Ordered list of arguments to pass to the script
|
||||||
|
|
||||||
"""
|
"""
|
||||||
result = { 'succeed': list(), 'failed': list() }
|
result = { 'succeed': {}, 'failed': {} }
|
||||||
hooks_dict = {}
|
hooks_dict = {}
|
||||||
|
|
||||||
# Retrieve hooks
|
# Retrieve hooks
|
||||||
|
@ -209,15 +209,15 @@ def hook_callback(action, hooks=[], args=None):
|
||||||
# Iterate over hooks and execute them
|
# Iterate over hooks and execute them
|
||||||
for priority in sorted(hooks_dict):
|
for priority in sorted(hooks_dict):
|
||||||
for name, info in iter(hooks_dict[priority].items()):
|
for name, info in iter(hooks_dict[priority].items()):
|
||||||
|
state = 'succeed'
|
||||||
filename = '%s-%s' % (priority, name)
|
filename = '%s-%s' % (priority, name)
|
||||||
try:
|
try:
|
||||||
hook_exec(info['path'], args=args)
|
hook_exec(info['path'], args=args)
|
||||||
except:
|
except:
|
||||||
logger.exception("error while executing hook '%s'",
|
logger.exception("error while executing hook '%s'",
|
||||||
info['path'])
|
info['path'])
|
||||||
result['failed'].append(filename)
|
state = 'failed'
|
||||||
else:
|
result[state][filename] = info['path']
|
||||||
result['succeed'].append(filename)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue