Use a finally clause to avoid duplicated code

This commit is contained in:
Alexandre Aubin 2019-03-04 17:21:57 +01:00
parent c191572a25
commit 877fe50685

View file

@ -403,13 +403,11 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
else:
returnjson = {}
except Exception as e:
raise YunohostError('hook_json_return_error', path=path, msg=str(e))
finally:
stdreturndir = os.path.split(stdreturn)[0]
os.remove(stdreturn)
os.rmdir(stdreturndir)
raise YunohostError('hook_json_return_error', path=path, msg=str(e))
stdreturndir = os.path.split(stdreturn)[0]
os.remove(stdreturn)
os.rmdir(stdreturndir)
return returncode, returnjson