os.system stdout redirection [to PyQt window]
Terry Gray
tgray at cox-internet.com
Sun Aug 17 14:47:11 EDT 2003
Donn Cave wrote:
> Quoth mackstann <mack at incise.org>:
> | On Sun, Aug 17, 2003 at 01:01:41AM -0500, Terry Gray wrote:
> |> Using Python 2.2 in Debian linuxI am trying to change to a different
> |> directory, execute a 'make all' command, and redirect the output of the
> |> subshell to a PyQt window... I should be able to execute the
> |> os.system('cd newdirectory; make all'), but how do I redirect stdout of
> |> the new subshell created by the os.system call?
>
> | You can use os.popen (popen2 and 3 as well), or the popen2 module's
> | Popen3 and 4 classes, or commands.getoutput (and there are probably even
> | more ways :).
>
> Yes, very good, there are many ways to redirect output, but you
> need to know how to make PyQt monitor a file and copy it to a window
> before it matters much either way.
>
> I don't know, so I've changed the subject line, replacing the elipsis
> ("..." - what was that for?) with [to PyQt window] to attract the
> attention of someone who might have a clue.
>
> Do you need to write this output line by line as it comes out of make?
> Or would it be fine to run make, and then wait to present all the output
> after it's finished? The latter is likely to be significantly easier.
>
> # make output goes to both units 1 and 2 (output and error/diagnostic)
> os.system('cd newdirectory; make all > make.log 2>&1')
> displayfile('newdirectory/make.log')
>
> Donn Cave, donn at drizzle.com
I need to display make's output line by line, since it a very long
compile cycle (kernel compile). Thanks for the help.
More information about the Python-list
mailing list