[elbe-devel] [PATCH 18/21] elbepack: pbuilder: call get_files() directly

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Aug 6 11:18:16 CEST 2024


Instead of going through "elbe control", call the get_files() method
directly. This reuses existing connections and improves the error
reporting.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/commands/pbuilder.py | 39 +++++++--------------------------------
 1 file changed, 7 insertions(+), 32 deletions(-)

diff --git a/elbepack/commands/pbuilder.py b/elbepack/commands/pbuilder.py
index 0277dd3738b8..97b6d4726bfc 100644
--- a/elbepack/commands/pbuilder.py
+++ b/elbepack/commands/pbuilder.py
@@ -9,7 +9,6 @@ import sys
 from elbepack.cli import add_argument, add_arguments_from_decorated_function
 from elbepack.commands.preprocess import add_xmlpreprocess_passthrough_arguments
 from elbepack.config import add_argument_sshport, add_arguments_soapclient
-from elbepack.directories import run_elbe
 from elbepack.filesystem import TmpdirFilesystem
 from elbepack.soapclient import ElbeSoapClient
 from elbepack.xmlpreprocess import preprocess_file
@@ -139,21 +138,10 @@ def _build(control, args):
         print('')
         print('Listing available files:')
         print('')
-        try:
-            run_elbe(['control', 'get_files', '--pbuilder-only', prjdir], check=True)
-        except subprocess.CalledProcessError:
-            print('elbe control get_files Failed', file=sys.stderr)
-            print('', file=sys.stderr)
-            print('dumping logfile', file=sys.stderr)
-
-            try:
-                run_elbe(['control', 'dump_file', prjdir, 'log.txt'], check=True)
-            except subprocess.CalledProcessError:
-                print('elbe control dump_file Failed', file=sys.stderr)
-                print('', file=sys.stderr)
-                print('Giving up', file=sys.stderr)
-
-            sys.exit(168)
+
+        files = control.get_files(prjdir, None, pbuilder_only=True)
+        for file in files:
+            print(f'{file.name}\t{file.description}')
 
         print('')
         print(f"Get Files with: 'elbe control get_file {prjdir} <filename>'")
@@ -162,22 +150,9 @@ def _build(control, args):
         print(f'Saving generated Files to {args.outdir}')
         print('')
 
-        try:
-            run_elbe(['control', 'get_files', '--pbuilder-only',
-                      '--output', args.outdir, prjdir], check=True)
-        except subprocess.CalledProcessError:
-            print('elbe control get_files Failed', file=sys.stderr)
-            print('', file=sys.stderr)
-            print('dumping logfile', file=sys.stderr)
-
-            try:
-                run_elbe(['control', 'dump_file', prjdir, 'log.txt'], check=True)
-            except subprocess.CalledProcessError:
-                print('elbe control dump_file Failed', file=sys.stderr)
-                print('', file=sys.stderr)
-                print('Giving up', file=sys.stderr)
-
-            sys.exit(169)
+        files = control.get_files(prjdir, args.outdir, pbuilder_only=True)
+        for file in files:
+            print(f'{file.name}\t{file.description}')
 
 
 _actions = {

-- 
2.46.0



More information about the elbe-devel mailing list