[PyQt] subprocess in PyQt

Mads Ipsen mpi at comxnet.dk
Sat Mar 14 10:43:41 GMT 2009


>
>
>
> Mads Ipsen-3 wrote:
>>
>>>
>>> Hello guys;
>>>
>>> i have a function that suppose to do something and from terminal it has
>>> this
>>> syntax to be executed;
>>>
>>> waseem at home:~/Desktop/Project2/GUI$ python myexif.py -q "pathfile" >
>>> test.csv
>>>
>>> so far on using subprocess i came up with this;
>>>
>>> from subprocess import *
>>> x=Popen(['python','myexif','-q','sys.argv[1]'], stdout=PIPE)
>>> y=Popen(['>','Exif.csv'], stdin=x.stdout)
>>>
>>> but i keep getting this error
>>>
>>> waseem at home:~/Desktop/Project2/GUI$ python wrapphotodb.py
>>> Traceback (most recent call last):
>>> File "wrapphotodb.py", line 37, in _addphotoClicked
>>> y=Popen(['>','Exif.csv'], stdin=x.stdout)
>>> File "/usr/lib/python2.5/subprocess.py", line 594, in __init__
>>> errread, errwrite)
>>> File "/usr/lib/python2.5/subprocess.py", line 1153, in _execute_child
>>> raise child_exception
>>> OSError: [Errno 2] No such file or directory
>>>
>>> Any idea? is my syntax correct?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/subprocess-in-PyQt-tp22510022p22510022.html
>>> Sent from the PyQt mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> PyQt mailing list    PyQt at riverbankcomputing.com
>>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>>
>>
>>
>> Why don't you try to use a QProcess from spawning external processes? I
>> have a good success ratio with that approach.
>>
>> Mads
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>>
>>
>
> Okay how am i going to use it? i read for sometimes i couldn't understand
>
> --
> View this message in context:
> http://www.nabble.com/subprocess-in-PyQt-tp22510022p22510772.html
> Sent from the PyQt mailing list archive at Nabble.com.
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>

Look here:

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qprocess.html

Here's a C++ snippet that needs very little modification in order to run
as a PyQt program:

The following example runs gzip to compress the string "Qt rocks!",
without an event loop:

     QProcess gzip;
     gzip.start("gzip", QStringList() << "-c");
     if (!gzip.waitForStarted())
         return false;

     gzip.write("Qt rocks!");
     gzip.closeWriteChannel();

     if (!gzip.waitForFinished())
         return false;

     QByteArray result = gzip.readAll();


More information about the PyQt mailing list