[projects/pld-builder.new] buildlogs: don't queue a buildlog that could not be compressed

arekm arekm at pld-linux.org
Mon Oct 26 17:16:36 CET 2026


commit b0323d4022511a8d2cc958fcc7b673d63fecead1
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sat Oct 24 11:32:57 2026 +0200

    buildlogs: don't queue a buildlog that could not be compressed
    
    file_sender retried the missing file forever.  Compress with the bz2
    module instead of a shell command.

 PLD_Builder/buildlogs.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/PLD_Builder/buildlogs.py b/PLD_Builder/buildlogs.py
index 311ae11..90d9170 100644
--- a/PLD_Builder/buildlogs.py
+++ b/PLD_Builder/buildlogs.py
@@ -1,9 +1,12 @@
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
+import bz2
+import contextlib
 import path
 import time
 import os
 import re
+import shutil
 import log
 
 from config import config
@@ -22,10 +25,16 @@ class Buildlogs_Queue:
             return
         blogfile = os.path.basename(logfile)
         name = re.sub(r"\.spec\.log", "", blogfile) + "," + id + ".bz2"
-        ret = os.system("bzip2 --best --force < %s > %s" \
-                    % (logfile, path.buildlogs_queue_dir + '/' + config.builder + '.' + id + '.' + blogfile))
-        if ret:
-            log.error("bzip2 compression of %s failed; does bzip2 binary exist?" % (logfile))
+        qfile = path.buildlogs_queue_dir + '/' + config.builder + '.' + id + '.' + blogfile
+        try:
+            with open(logfile, 'rb') as f_in, bz2.open(qfile, 'wb', compresslevel=9) as f_out:
+                shutil.copyfileobj(f_in, f_out)
+        except OSError as e:
+            # queueing it anyway would make file_sender retry a missing file forever
+            log.error(f"compressing buildlog {logfile} failed, not sending it: {e}")
+            with contextlib.suppress(FileNotFoundError):
+                os.unlink(qfile)
+            return
 
         if failed: s = "FAIL"
         else: s = "OK"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/ce9feb3c796ed049b6dd260a50d94d80feb1656d



More information about the pld-cvs-commit mailing list