# Log messages to here
self.logger = logger
- def __str__(self):
- config = self._make_config()
-
- return self._to_string(config)
-
- def _to_string(self, config):
- buffer = io.StringIO()
- config.write(buffer)
-
- return buffer.getvalue()
-
# Repositories
async def fetch_repos(self):
if self.logger:
ctx.set_logger(self.logger)
- f = io.StringIO()
-
# Make configuration
- config = await self._make_config(local=True)
+ config = await self.config(local=True)
- # Write the configuration to the buffer
- config.write(f)
- f.seek(0)
-
- log.debug("Launching Pakfire with configuration:\n%s", f.getvalue())
+ log.debug("Launching Pakfire with configuration:\n%s", config.getvalue())
# Launch a new Pakfire instance (in a separate thread)
async with self.backend.tempdir() as d:
- return await asyncio.to_thread(pakfire.Pakfire, ctx=ctx, path=d, arch=self.arch, conf=f)
+ return await asyncio.to_thread(pakfire.Pakfire, ctx=ctx, path=d, arch=self.arch, conf=config)
async def __aexit__(self, type, value, traceback):
pass
- async def _make_config(self, local=False):
+ async def config(self, local=False):
"""
Generates the configuration file
"""
repo.write_config(config, local=local, include_source=self.include_source,
mirrored=self.mirrored, build=self.build)
- return config
+ # Allocate a buffer and write the configuration to it
+ f = io.StringIO()
+ config.write(f)
+
+ # Rewind the buffer
+ f.seek(0)
+
+ return f
class PakfireLogger(object):