[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [PATCH] Log everything from execWithRedirect or execWithCapture to a file.
- From: Chris Lumens <clumens redhat com>
- To: anaconda-devel-list redhat com
- Subject: Re: [PATCH] Log everything from execWithRedirect or execWithCapture to a file.
- Date: Wed, 7 Jan 2009 08:28:28 -0500
> You are changing the behavior of execWithCapture, you are now also
> capturing the stderr output!
Ah, whoops. See my comment below for how to fix it.
- Chris
>> @@ -93,17 +115,30 @@ def execWithCapture(command, argv, stdin = 0, stderr = 2, root='/'):
>> if type(stderr) == type("string"):
>> stderr = open(stderr, "w")
>> + runningLog = open("/tmp/program.log", "a")
>> + runningLog.write("Running... %s\n" % ([command] + argv,))
>> +
>> try:
>> - pipe = subprocess.Popen([command] + argv, stdin=stdin,
>> + proc = subprocess.Popen([command] + argv, stdin=stdin,
>> stdout=subprocess.PIPE,
>> - stderr=subprocess.STDOUT,
>> + stderr=subprocess.PIPE,
>> preexec_fn=chroot, cwd=root)
>> +
>> + while True:
>> + (outStr, errStr) = proc.communicate()
>> + if outStr:
>> + runningLog.write(outStr)
>> + rc += outStr
>> + if errStr:
>> + runningLog.write(errStr)
>> + rc += errStr
Remove this rc += errStr and replace it with
sys.__stdout__.write(errStr). That at least gets us back to the
previous behavior of not capturing stderr. What we probably should do
is write it to wherever the stderr parameter tells us to - we even open
a location for it above, but never do anything with it.
>> +
>> + if proc.returncode is not None:
>> + break
>> except OSError, (errno, msg):
>> log.error ("Error running " + command + ": " + msg)
>> raise RuntimeError, "Error running " + command + ": " + msg
>> - rc = pipe.stdout.read()
>> - pipe.wait()
>> return rc
>> def execWithPulseProgress(command, argv, stdin = 0, stdout = 1,
>> stderr = 2,
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]