mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] allow hook_exec to have custom callbacks
This commit is contained in:
parent
933c56bb7e
commit
274a219fdc
1 changed files with 4 additions and 3 deletions
|
@ -297,7 +297,8 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None,
|
|||
|
||||
|
||||
def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||
chdir=None, env=None, user="admin"):
|
||||
chdir=None, env=None, user="admin", stdout_callback=None,
|
||||
stderr_callback=None):
|
||||
"""
|
||||
Execute hook from a file with arguments
|
||||
|
||||
|
@ -361,8 +362,8 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
|||
|
||||
# Define output callbacks and call command
|
||||
callbacks = (
|
||||
lambda l: logger.debug(l.rstrip()),
|
||||
lambda l: logger.warning(l.rstrip()),
|
||||
stdout_callback if stdout_callback else lambda l: logger.debug(l.rstrip()),
|
||||
stderr_callback if stderr_callback else lambda l: logger.warning(l.rstrip()),
|
||||
)
|
||||
returncode = call_async_output(
|
||||
command, callbacks, shell=False, cwd=chdir
|
||||
|
|
Loading…
Add table
Reference in a new issue