[elbe-devel] [PATCH 5/5] elbepack: shellhelper: allow specification of additional kwargs

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon May 6 10:07:51 CEST 2024


The shellhelper package is only a thin wrapper around the stdlib
subprocess package. Allow other useful arguments to be used.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/shellhelper.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/elbepack/shellhelper.py b/elbepack/shellhelper.py
index e82a3b3dbaff..f5f27a2b5a0c 100644
--- a/elbepack/shellhelper.py
+++ b/elbepack/shellhelper.py
@@ -22,7 +22,7 @@ def _log_cmd(cmd):
         return shlex.join(map(os.fspath, cmd))
 
 
-def do(cmd, /, *, check=True, input=None, env_add=None, log_cmd=None):
+def do(cmd, /, *, check=True, input=None, env_add=None, log_cmd=None, **kwargs):
     """do() - Execute cmd in a shell and redirect outputs to logging.
 
     Throws a subprocess.CalledProcessError if cmd returns none-zero and check=True
@@ -62,7 +62,7 @@ def do(cmd, /, *, check=True, input=None, env_add=None, log_cmd=None):
 
     with async_logging_ctx() as w:
         subprocess.run(cmd, shell=_is_shell_cmd(cmd), stdout=w, stderr=subprocess.STDOUT,
-                       env=new_env, check=check, input=input)
+                       env=new_env, check=check, input=input, **kwargs)
 
 
 def chroot(directory, cmd, /, *, env_add=None, **kwargs):
@@ -94,7 +94,7 @@ def chroot(directory, cmd, /, *, env_add=None, **kwargs):
         do(['chroot', directory] + cmd, env_add=new_env, **kwargs)
 
 
-def get_command_out(cmd, /, *, input=None, check=True, env_add=None):
+def get_command_out(cmd, /, *, input=None, check=True, env_add=None, **kwargs):
     """get_command_out() - Like do() but returns stdout.
 
     --
@@ -129,7 +129,7 @@ def get_command_out(cmd, /, *, input=None, check=True, env_add=None):
 
     with async_logging_ctx() as w:
         ps = subprocess.run(cmd, shell=_is_shell_cmd(cmd), stdout=subprocess.PIPE, stderr=w,
-                            env=new_env, check=check, input=input)
+                            env=new_env, check=check, input=input, **kwargs)
         return ps.stdout
 
 

-- 
2.45.0



More information about the elbe-devel mailing list