mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Use a finally clause to avoid duplicated code
This commit is contained in:
parent
c191572a25
commit
877fe50685
1 changed files with 3 additions and 5 deletions
|
@ -403,13 +403,11 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||||
else:
|
else:
|
||||||
returnjson = {}
|
returnjson = {}
|
||||||
except Exception as e:
|
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.remove(stdreturn)
|
||||||
os.rmdir(stdreturndir)
|
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
|
return returncode, returnjson
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue