return buffer.getvalue()
- def _log(self, level, message):
- # Remove any trailing newline (but only one)
- if message:
- message = message.removesuffix("\n")
-
- # Log to the logger if configured
- if self.logger:
- return self.logger(level, message)
-
- return log.log(level, message)
-
# Repositories
def add_repo(self, repo):
# Context
async def __aenter__(self):
+ # Setup a new context
+ ctx = pakfire.Ctx()
+
+ # Set the cache path
+ #ctx.cache_path = "/pub/pakfire/.cache"
+
+ # Configure the logger
+ if self.logger:
+ ctx.set_logger(self.logger)
+
f = io.StringIO()
# Make configuration
# Launch a new Pakfire instance (in a separate thread)
async with self.backend.tempdir() as d:
- return await asyncio.to_thread(pakfire.Pakfire, path=d, arch=self.arch, conf=f)
+ return await asyncio.to_thread(pakfire.Pakfire, ctx=ctx, path=d, arch=self.arch, conf=f)
async def __aexit__(self, type, value, traceback):
pass
# Register the queue with the logger
self.log.addHandler(handler)
- def __call__(self, *args, **kwargs):
- """
- Logs a message
- """
- return self.log.log(*args, **kwargs)
-
def __str__(self):
"""
Returns the entire log as a string
"""
return "\n".join((record.getMessage() for record in self.queue))
+
+ def log(self, *args, **kwargs):
+ """
+ Logs a message
+ """
+ return self.log.log(*args, **kwargs)