[elbe-devel] [PATCH 14/18] elbepack: initvm: call dump_file() directly

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Aug 13 13:15:44 CEST 2024


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

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

diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index 34b361fc0174..748a6cf3ab48 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -175,18 +175,20 @@ def _submit_and_dl_result(control, xmlfile, cdrom, args):
         print('')
 
     try:
-        run_elbe(['control', 'dump_file', prjdir, 'validation.txt'], check=True)
-    except subprocess.CalledProcessError:
+        for chunk in control.dump_file(prjdir, 'validation.txt'):
+            sys.stdout.buffer.write(chunk)
+        sys.stdout.buffer.flush()
+    except Exception:
         print(
             'Project failed to generate validation.txt',
             file=sys.stderr)
         print('Getting log.txt', file=sys.stderr)
         try:
-            run_elbe(['control', 'dump_file', prjdir, 'log.txt'], check=True)
-        except subprocess.CalledProcessError:
-
-            print('Failed to dump log.txt', file=sys.stderr)
-            print('Giving up', file=sys.stderr)
+            for chunk in control.dump_file(prjdir, 'log.txt'):
+                sys.stdout.buffer.write(chunk)
+            sys.stdout.buffer.flush()
+        except Exception as e:
+            raise with_cli_details(e, 137, textwrap.dedent('Failed to dump log.txt'))
         sys.exit(136)
 
     if args.skip_download:

-- 
2.46.0



More information about the elbe-devel mailing list