]> git.ipfire.org Git - pbs.git/commitdiff
backend: Add an easy way to open a package file
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jun 2022 15:41:08 +0000 (15:41 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 21 Jun 2022 15:41:08 +0000 (15:41 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py

index 7abb5f2d4daa46daf6a2f572172f054d73ba41b6..08f47b8b45b4dbb46011d92d657fc1cbdc0ccef0 100644 (file)
@@ -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)