]> git.ipfire.org Git - pbs.git/commitdiff
config: Pass configuration as file object
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 2 Aug 2023 15:36:26 +0000 (15:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 2 Aug 2023 16:54:58 +0000 (16:54 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/config.py

index 65c237b0467629f06c35a36ccb37af837cccd5e4..d0cd3e2872a6ceec1c3c69cc4e18d797e105d263 100644 (file)
@@ -76,21 +76,20 @@ class PakfireConfig(base.Object):
        # Context
 
        async def __aenter__(self):
+               f = io.StringIO()
+
                # Make configuration
                config = self._make_config(local=True)
 
-               log.debug("Launching Pakfire with configuration:\n%s", self._to_string(config))
-
-               async with self.backend.tempfile(mode="w+") as t:
-                       # Write the configuration to disk
-                       config.write(t)
-                       t.flush()
+               # Write the configuration to the buffer
+               config.write(f)
+               f.seek(0)
 
-                       # Launch a new Pakfire instance (in a separate thread)
-                       p = await asyncio.to_thread(pakfire.Pakfire, arch=self.arch, conf=t.name,
-                               logger=self._log, offline=False)
+               log.debug("Launching Pakfire with configuration:\n%s", f.getvalue())
 
-               return p
+               # Launch a new Pakfire instance (in a separate thread)
+               return await asyncio.to_thread(pakfire.Pakfire, arch=self.arch, conf=f,
+                       logger=self._log, offline=False)
 
        async def __aexit__(self, type, value, traceback):
                pass