]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
Fix output of shell commands in makefiles.
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 23 Oct 2012 19:01:58 +0000 (21:01 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 23 Oct 2012 19:01:58 +0000 (21:01 +0200)
Error output is now thrown away and the wanted output
is not written to the logfiles anymore.

python/pakfire/chroot.py
python/pakfire/packages/lexer.py

index 9862dc74b85b1affc9e5406696fc5fc3977cca3d..c08bbdb394c8f7d21248f3b6de6c93a30cb4112d 100644 (file)
@@ -79,7 +79,7 @@ def logOutput(fds, logger, returnOutput=1, start=0, timeout=0):
        return output
 
 
-def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True, returnOutput=0, personality=None, logger=None, env=None, cgroup=None, *args, **kargs):
+def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True, returnOutput=0, logstderr=1, personality=None, logger=None, env=None, cgroup=None, *args, **kargs):
        # Save the output of command
        output = ""
 
@@ -94,6 +94,11 @@ def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True
 
        child = None
 
+       if logstderr:
+               stderr = subprocess.PIPE
+       else:
+               stderr = open("/dev/null", "w")
+
        try:
                # Create new child process
                child = subprocess.Popen(
@@ -102,7 +107,7 @@ def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True
                        bufsize=0, close_fds=True, 
                        stdin=open("/dev/null", "r"), 
                        stdout=subprocess.PIPE,
-                       stderr=subprocess.PIPE,
+                       stderr=stderr,
                        preexec_fn = preexec,
                        env=env
                )
@@ -112,7 +117,11 @@ def do(command, shell=False, chrootPath=None, cwd=None, timeout=0, raiseExc=True
                        cgroup.attach_task(child.pid)
 
                # use select() to poll for output so we dont block
-               output = logOutput([child.stdout, child.stderr], logger, returnOutput, start, timeout)
+               fds = [child.stdout,]
+               if logstderr:
+                       fds.append(child.stderr)
+
+               output = logOutput(fds, logger, returnOutput, start, timeout)
 
        except:
                # kill children if they aren't done
index 52eeb1978faf5c8e1f562356d34bc5f41ef8e287..38445d833dfd128abbf74e1b5bc528c595c9e292 100644 (file)
@@ -238,7 +238,7 @@ class Lexer(object):
 
                # Do we need to chroot and change personality?
                try:
-                       output = pakfire.chroot.do(command, shell=True, returnOutput=1, logger=log)
+                       output = pakfire.chroot.do(command, shell=True, returnOutput=1, logstderr=False)
 
                except Error:
                        return