Fix listing of succeed/failed hook names

This commit is contained in:
Alexandre Aubin 2019-03-04 17:44:20 +01:00
parent 877fe50685
commit c74bff31d1

View file

@ -493,11 +493,14 @@ def service_regen_conf(operation_logger, names=[], with_diff=False, force=False,
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 # Keep only the hook names with at least one success
names = {n: [p for p, c in v.items() if c['state'] == "failed"] for n, v in pre_result.items()}.keys() names = [hook for hook, infos in pre_result.items()
if any(result["state"] == "succeed" for result in infos.values())]
# FIXME : what do in case of partial success/failure ...
if not names: if not names:
ret_failed = {n: [p for p, c in v.items() if c['state'] == "failed"] for n, v in pre_result.items()} ret_failed = [hook for hook, infos in pre_result.items()
if any(result["state"] == "failed" for result in infos.values())]
raise YunohostError('service_regenconf_failed', raise YunohostError('service_regenconf_failed',
services=', '.join(ret_failed)) services=', '.join(ret_failed))