[elbe-devel] [PATCH 4/9] elbepack: directories: introduce helper to execute an elbe subcommand

Thomas Weißschuh thomas.weissschuh at linutronix.de
Thu Jul 25 11:47:14 CEST 2024


In contrast to the existing run_elbe() helper,
run_elbe_subcommand() executes the subcommand in the same
interpreter/process.
This has the advantage that all environment and stacktraces are
preserved.
For now this is useful for unittests but as soon as the exception-based
error handling is active it can be used throughout elbe.

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

diff --git a/elbepack/directories.py b/elbepack/directories.py
index 8c5d5caac75d..e58a7e50841a 100644
--- a/elbepack/directories.py
+++ b/elbepack/directories.py
@@ -2,9 +2,18 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 # SPDX-FileCopyrightText: 2015, 2017 Linutronix GmbH
 
+import os
 import subprocess
 import sys
 
+import elbepack.main
+
 
 def run_elbe(args, **kwargs):
     return subprocess.run([sys.executable, '-melbepack', *args], **kwargs)
+
+
+def run_elbe_subcommand(args):
+    return elbepack.main.main([
+        'elbe', *[os.fspath(arg) for arg in args],
+    ])

-- 
2.45.2



More information about the elbe-devel mailing list