From: Michael Tremer Date: Tue, 21 Jun 2022 15:41:08 +0000 (+0000) Subject: backend: Add an easy way to open a package file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6b53ad16702f6f3867b054ef5018e65ba9bbd2f;p=pbs.git backend: Add an easy way to open a package file Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index 7abb5f2d..08f47b8b 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -1,7 +1,6 @@ #!/usr/bin/python - - +import asyncio import configparser import logging import os @@ -127,6 +126,19 @@ class Backend(object): return database.Connection(hostname, name, user=user, password=password) + async def open(self, path): + """ + Opens a package and returns the archive + """ + return await asyncio.to_thread(self._open, path) + + def _open(self, path): + # Create a dummy Pakfire instance + p = pakfire.Pakfire(offline=True) + + # Open the archive + return p.open(path) + def delete_file(self, path, not_before=None): self.db.execute("INSERT INTO queue_delete(path, not_before) \ VALUES(%s, %s)", path, not_before)