Ingmar Steen a écrit :



Hi,

That won't work because the '>' (redirect) you use in a shell
environment doesn't 'magically' work. The shell (bash, ksh, etc)
performs the job of capturing the child process' 'stdout' (the regular
output of the process) and redirects it to a file.

To achieve that you can do two things:
1) The proper way: Use the fact that QProcess allows you to read the
child process' stdout and write it to a file yourself.

From the documentation:

QProcess allows you to treat a process as a sequential I/O device. You
can write to and read from the process just as you would access a
network connection using QTcpSocket. You can then write to the
process's standard input by calling write(), and read the standard
output by calling read(), readLine(), and getChar(). Because it
inherits QIODevice, QProcess can also be used as an input source for
QXmlReader, or for generating data to be uploaded using QFtp.

2) The dirty way: Use a shell to do this for you (and lose
cross-platform compatibility as an added bonus!)
Instead of spawning your process, spawn a shell:
command = 'sh'
args = ['-c', 'lout myfile.lout > myfile.ps']

I really do suggest you take option 1.


Ok, thanks Ingmar.

I'm already catching the output to view it inside a QTextEdit (sort of log viewer), via something like this :

self.connect(self.proc,QtCore.SIGNAL("readyReadStandardOutput()"),self.viewOutput)

When I do :

self.proc.start("pdflatex", QtCore.QStringList(["my_file.tex"]))

My pdf file is generated and I can view my output in the log view.

When I do :

self.proc.start("lout", QtCore.QStringList(["my_file.lout",">
","my_file.ps"]))

the ps file I was waiting for is seen in my log viewer in text mode, as you pointed out.

In fact, I think I just need a flag to redirect or not the output to a file and use only:

self.proc.start("lout", QtCore.QStringList(["my_file.lout"]))

Thanks again,

Christophe.
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to