[elbe-devel] [PATCH 5/5] elbepack: shellhelper: implement do() in terms of run()

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue May 28 12:38:52 CEST 2024


Deduplicate some logic.

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

diff --git a/elbepack/shellhelper.py b/elbepack/shellhelper.py
index 169308efd4d3..59982ed67360 100644
--- a/elbepack/shellhelper.py
+++ b/elbepack/shellhelper.py
@@ -91,7 +91,7 @@ def run(cmd, /, *, check=True, log_cmd=None, **kwargs):
         return subprocess.run(cmd, stdout=stdout, stderr=stderr, check=check, **kwargs)
 
 
-def do(cmd, /, *, check=True, env_add=None, log_cmd=None, **kwargs):
+def do(cmd, /, *, env_add=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
@@ -127,11 +127,8 @@ def do(cmd, /, *, check=True, env_add=None, log_cmd=None, **kwargs):
     if env_add:
         new_env.update(env_add)
 
-    logging.info(log_cmd or _log_cmd(cmd), extra={'context': '[CMD] '})
-
-    with async_logging_ctx() as w:
-        subprocess.run(cmd, shell=_is_shell_cmd(cmd), stdout=w, stderr=subprocess.STDOUT,
-                       env=new_env, check=check, **kwargs)
+    run(cmd, shell=_is_shell_cmd(cmd), env=new_env, stdout=ELBE_LOGGING, stderr=subprocess.STDOUT,
+        **kwargs)
 
 
 def chroot(directory, cmd, /, *, env_add=None, **kwargs):

-- 
2.45.1



More information about the elbe-devel mailing list