[PyQt] subprocess in PyQt

Giovanni Bajo rasky at develer.com
Sun Mar 15 10:46:33 GMT 2009


On sab, 2009-03-14 at 23:24 +0200, Ville M. Vainio wrote:
> On Sat, Mar 14, 2009 at 9:17 AM, klia <alwaseem307ster at yahoo.com> wrote:
> 
> > 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)
> 
> the y=... line doesn't make much sense.
> 
> Why not just do os.system('myexif.py -q "pathfile" > test.csv') and be
> done with it? If you don't care about your UI blocking for a second,
> it should be rather trouble-free...

This makes use of the shell though. If you don't want to run another
shell, you can use:

Popen(['python','myexif','-q',sys.argv[1]],
      stdout=open("Exif.csv","w"),
      shell=False)

-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com




More information about the PyQt mailing list