From: Michael Tremer Date: Wed, 2 Aug 2023 15:36:26 +0000 (+0000) Subject: config: Pass configuration as file object X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ca2b3bbdd24be83fa00d1b9906e3930e392f2b3;p=pbs.git config: Pass configuration as file object Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/config.py b/src/buildservice/config.py index 65c237b0..d0cd3e28 100644 --- a/src/buildservice/config.py +++ b/src/buildservice/config.py @@ -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