Re: [PATCH] Log everything from execWithRedirect or execWithCapture to a file.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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,

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux