mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Use yaml for reading hook output
This commit is contained in:
parent
fddb79e841
commit
a89dd4827c
1 changed files with 4 additions and 4 deletions
|
@ -34,7 +34,7 @@ from importlib import import_module
|
||||||
from moulinette import m18n, msettings
|
from moulinette import m18n, msettings
|
||||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||||
from moulinette.utils import log
|
from moulinette.utils import log
|
||||||
from moulinette.utils.filesystem import read_json
|
from moulinette.utils.filesystem import read_yaml
|
||||||
|
|
||||||
HOOK_FOLDER = "/usr/share/yunohost/hooks/"
|
HOOK_FOLDER = "/usr/share/yunohost/hooks/"
|
||||||
CUSTOM_HOOK_FOLDER = "/etc/yunohost/hooks.d/"
|
CUSTOM_HOOK_FOLDER = "/etc/yunohost/hooks.d/"
|
||||||
|
@ -326,7 +326,7 @@ def hook_exec(
|
||||||
chdir=None,
|
chdir=None,
|
||||||
env=None,
|
env=None,
|
||||||
user="root",
|
user="root",
|
||||||
return_format="json",
|
return_format="yaml",
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Execute hook from a file with arguments
|
Execute hook from a file with arguments
|
||||||
|
@ -447,10 +447,10 @@ def _hook_exec_bash(path, args, chdir, env, user, return_format, loggers):
|
||||||
raw_content = f.read()
|
raw_content = f.read()
|
||||||
returncontent = {}
|
returncontent = {}
|
||||||
|
|
||||||
if return_format == "json":
|
if return_format == "yaml":
|
||||||
if raw_content != "":
|
if raw_content != "":
|
||||||
try:
|
try:
|
||||||
returncontent = read_json(stdreturn)
|
returncontent = read_yaml(stdreturn)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise YunohostError(
|
raise YunohostError(
|
||||||
"hook_json_return_error",
|
"hook_json_return_error",
|
||||||
|
|
Loading…
Add table
Reference in a new issue