From: Michael Tremer Date: Wed, 19 Oct 2022 14:36:51 +0000 (+0000) Subject: jobs: Attempt opening logs in text mode X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b10cea53c3e910adcbd02b9d71c2dfd58e193140;p=pbs.git jobs: Attempt opening logs in text mode Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index a36cf137..4bde08b1 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -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