[elbe-devel] [PATCH 1/4] elbepack: soap: return array from list_packages()

Thomas Weißschuh thomas.weissschuh at linutronix.de
Fri Jul 19 14:17:43 CEST 2024


Instead of constructing the final string server-side return an array,
so the client can do whatever it wants with the raw data.

This also avoids a bug, where an empty string would get converted to
"None" at some point.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/daemons/soap/esoap.py | 8 ++++----
 elbepack/soapclient.py         | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
index e1534ad87550..e6e0d1766e5e 100644
--- a/elbepack/daemons/soap/esoap.py
+++ b/elbepack/daemons/soap/esoap.py
@@ -336,17 +336,17 @@ class ESoap (ServiceBase):
         self.app.pm.open_project(uid, builddir)
         self.app.pm.rm_log(uid)
 
-    @rpc(String, _returns=String)
+    @rpc(String, _returns=String.customize(max_occurs='unbounded'))
     @authenticated_uid
     @soap_faults
     def list_packages(self, uid, builddir):
         self.app.pm.open_project(uid, builddir)
-        s = ''
+        r = []
         for _, _, filenames in os.walk(
                 os.path.join(builddir, 'repo/pool/main')):
             for filename in fnmatch.filter(filenames, '*.deb'):
-                s += filename + '\n'
-        return s
+                r.append(filename)
+        return sorted(r)
 
     @rpc(String, String)
     @authenticated_uid
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index afa85adca047..caa9a4daf147 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -743,7 +743,8 @@ class ListPackagesAction(RepoAction):
             sys.exit(199)
 
         builddir = args[0]
-        print(client.service.list_packages(builddir))
+        for pkg in client.service.list_packages(builddir):
+            print(pkg)
 
 
 RepoAction.register(ListPackagesAction)

-- 
2.45.2



More information about the elbe-devel mailing list