[elbe-devel] [PATCH 13/18] elbepack: soapclient: make dump_file() a method on ElbeSoapClient
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Tue Aug 13 13:15:43 CEST 2024
This is useful functionality that should be usable without going through
"elbe control".
Make it a library function that can be called from other parts of elbe
and call it from "elbe control".
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/commands/control.py | 12 +++---------
elbepack/soapclient.py | 10 ++++++++++
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/elbepack/commands/control.py b/elbepack/commands/control.py
index 528574587b1f..3beda07e3f5a 100644
--- a/elbepack/commands/control.py
+++ b/elbepack/commands/control.py
@@ -3,7 +3,6 @@
# SPDX-FileCopyrightText: 2014-2017 Linutronix GmbH
import argparse
-import binascii
import os
import socket
import sys
@@ -137,14 +136,9 @@ def _build_chroot(client, args):
@_add_project_dir_argument
@add_argument('file')
def _dump_file(client, args):
- part = 0
- while True:
- ret = client.service.get_file(args.project_dir, args.file, part)
- if ret == 'EndOfFile':
- return
-
- os.write(sys.stdout.fileno(), binascii.a2b_base64(ret))
- part = part + 1
+ for chunk in client.dump_file(args.project_dir, args.file):
+ sys.stdout.buffer.write(chunk)
+ sys.stdout.buffer.flush()
@add_argument('--output', help='Output files to <directory>')
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index 6fbc9eeb586a..8b8a685e2c1b 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -228,3 +228,13 @@ class ElbeSoapClient:
self.download_file(builddir, f.name, dst_fname)
return result
+
+ def dump_file(self, builddir, file):
+ part = 0
+ while True:
+ ret = self.service.get_file(builddir, file, part)
+ if ret == 'EndOfFile':
+ return
+
+ yield binascii.a2b_base64(ret)
+ part = part + 1
--
2.46.0
More information about the elbe-devel
mailing list