]> git.ipfire.org Git - pbs.git/commitdiff
jobs: Attempt opening logs in text mode
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Oct 2022 14:36:51 +0000 (14:36 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Oct 2022 14:36:51 +0000 (14:36 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/jobs.py

index a36cf137744bfdd19365f6ba23c8e1d4238128ad..4bde08b1727c6216727cae5f70808fe0d7994be1 100644 (file)
@@ -376,7 +376,7 @@ class Job(base.DataObject):
        def log_digest_blake2s(self):
                return self.data.log_digest_blake2s
 
-       async def open_log(self):
+       async def open_log(self, mode="r"):
                """
                        Opens the log file, and returns an open file handle
                """
@@ -384,18 +384,18 @@ class Job(base.DataObject):
                if not self.has_log():
                        raise FileNotFoundError
 
-               return await asyncio.to_thread(self._open_log)
+               return await asyncio.to_thread(self._open_log, mode)
 
-       def _open_log(self):
+       def _open_log(self, mode):
                path = self.log_path
 
                # Open gzip-compressed files
                if path.endswith(".gz"):
-                       return gzip.open(path)
+                       return gzip.open(path, mode)
 
                # Open uncompressed files
                else:
-                       return open(open)
+                       return open(open, mode)
 
        async def _import_log(self, upload):
                # Create some destination path