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

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

 





Chris Lumens wrote:
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.


Seems like an ok solution, but it would be better to log it to the specified file, while we are making changes.

Regards,

Hans

_______________________________________________
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