[Tutor] Can you help me with subprocess module ?.

PyProg PyProg pyprog05 at gmail.com
Wed Feb 4 00:39:09 CET 2009


Hello everyone,

I have a problem with the subprocess module. In fact I wish that when
I run the command with subprocess I can retrieve the data immediately
without waiting for the end of the command. I tried this way but
ordering must end so that I can recover the data:

import subprocess, os, sys

# Commande FFmpeg
com_1 = 'ffmpeg -i /home/user/path/in.avi -s 160x120 -ac 1 -ar 22050
-qmin 3 -qmax 3 -y /home/user/path/out.avi'

p = [subprocess.Popen(com_1, stderr=subprocess.STDOUT,
stdout=subprocess.PIPE, shell=True).communicate()[0]]

for toto in p:
---->if '\r' in toto:
-------->tampon = str(toto).split(' ')
--------># ..., 'time=151.6', ...
-------->for vb in tampon:
------------>if 'time' in vb:
---------------->tempsEcoule = vb[5:]
---------------->print u'Temps écoulé', tempsEcoule

My version of Python:

Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2

Can you help me?.

Excuse me in advance for my bad English.

a +

-- 
http://ekd.tuxfamily.org


More information about the Tutor mailing list