pld-builder.new: PLD_Builder/chroot.py, PLD_Builder/upgrade.py - u...

arekm arekm at pld-linux.org
Thu Sep 22 20:33:31 CEST 2005


Author: arekm                        Date: Thu Sep 22 18:33:31 2005 GMT
Module: pld-builder.new               Tag: HEAD
---- Log message:
- use stringio for stdout log handling, simplifies things

---- Files affected:
pld-builder.new/PLD_Builder:
   chroot.py (1.17 -> 1.18) , upgrade.py (1.8 -> 1.9) 

---- Diffs:

================================================================
Index: pld-builder.new/PLD_Builder/chroot.py
diff -u pld-builder.new/PLD_Builder/chroot.py:1.17 pld-builder.new/PLD_Builder/chroot.py:1.18
--- pld-builder.new/PLD_Builder/chroot.py:1.17	Thu Sep 15 21:12:24 2005
+++ pld-builder.new/PLD_Builder/chroot.py	Thu Sep 22 20:33:25 2005
@@ -21,22 +21,19 @@
     f = os.popen(command(cmd, user), mode)
     return f
     
-def run(cmd, user = "builder", logfile = None, logstdout = False):
+def run(cmd, user = "builder", logfile = None, logstdout = None):
     c = command(cmd, user)
     if logfile != None:
-        if logstdout:
-            c = "%s 2>&1 | tee %s" % (c, logfile)
+        if logstdout != None:
+            c = "%s 2>&1 | /usr/bin/tee -a %s" % (c, logfile)
         else:
             c = "%s >> %s 2>&1" % (c, logfile)
-    lines = ""
     f = os.popen(c)
     for l in f:
-        lines += l
+        if logstdout != None:
+            logstdout.write(l)
     r = f.close()
     if r == None:
-        if logstdout:
-            return lines
-        else:
-            return 0
+        return 0
     else:
         return r

================================================================
Index: pld-builder.new/PLD_Builder/upgrade.py
diff -u pld-builder.new/PLD_Builder/upgrade.py:1.8 pld-builder.new/PLD_Builder/upgrade.py:1.9
--- pld-builder.new/PLD_Builder/upgrade.py:1.8	Thu Sep 15 21:12:24 2005
+++ pld-builder.new/PLD_Builder/upgrade.py	Thu Sep 22 20:33:25 2005
@@ -2,6 +2,7 @@
 
 import re
 import string
+import StringIO
 
 import chroot
 import util
@@ -66,14 +67,13 @@
             b.log_line("upgrade would need removal of %s" % k)
             return False
     b.log_line("upgrading packages")
-    res = chroot.run("rpm -Fvh %s" % string.join(b.files), user = "root", logstdout = True)
-    if hasattr(res, '__int__'):
-        if res != 0:
-            b.log_line("package upgrade failed")
-            return False
-        return True
-    if res:
-        for line in res:
-            b.log_line(line)
-            return True
-    return False
+    logbuf = StringIO.StringIO()
+    res = chroot.run("rpm -Fvh %s" % string.join(b.files), user = "root", logstdout = logbuf)
+    if res != 0:
+        b.log_line("package upgrade failed")
+        b.log_line(logbuf.getvalue())
+        logbuf.close()
+        return False
+    b.log_line(logbuf.getvalue())
+    logbuf.close()
+    return True
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/pld-builder.new/PLD_Builder/chroot.py?r1=1.17&r2=1.18&f=u
    http://cvs.pld-linux.org/pld-builder.new/PLD_Builder/upgrade.py?r1=1.8&r2=1.9&f=u




More information about the pld-cvs-commit mailing list