Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Getting output from external programs...

Reply
Thread Tools

Re: Getting output from external programs...

 
 
Ten
Guest
Posts: n/a
 
      06-19-2006
On Sunday 18 June 2006 21:28, ph0b0s wrote:
> Hi,
>
> i'm making an mp3 conversion program in Python, but am kind of stuck now.
> The conversion routines work, using LAME, but now a i'm building a GUI
> *with GLADE around it, and would like to be able to show LAME's output
> *to the user in a status window in my gui.. but don't know where to
> start...
>
> The command i use to invoke LAME is this :
> command = ("lame -b " + str(bitrate) + " " + infile + " \"" +
> dir_outpath + separator + outfile + "\"")
>
> *** ** **



You can do this in various ways, ranging from the very simple and not very good

from commands import getoutput

x=getoutput(command)


- to your more common and better popens.

ie:

import popen2

(stdOut, stdIn) = popen2.popen4(command)

x=stdOut.readlines()

- asynchronously if appropriate.

How are you running the command at the moment?



--
There are 10 types of people in this world,
those who understand binary, and those who don't.
 
Reply With Quote
 
 
 
 
Cameron Laird
Guest
Posts: n/a
 
      06-19-2006
In article <(E-Mail Removed)>,
Ten <(E-Mail Removed)> wrote:
.
.
.
>You can do this in various ways, ranging from the very simple and not very good
>
>from commands import getoutput
>
>x=getoutput(command)
>
>
>- to your more common and better popens.
>
>ie:
>
>import popen2
>
>(stdOut, stdIn) = popen2.popen4(command)
>
>x=stdOut.readlines()
>
>- asynchronously if appropriate.
>
>How are you running the command at the moment?

.
.
.
Why deprecate commands.getoutput()? Are you merely
observing that it's applicable in fewer circumstances?
 
Reply With Quote
 
 
 
 
Ten
Guest
Posts: n/a
 
      06-19-2006
On Monday 19 June 2006 03:44, Cameron Laird wrote:
> In article <(E-Mail Removed)>,
> Ten <(E-Mail Removed)> wrote:
>
> >You can do this in various ways, ranging from the very simple and not very
> > good
> >
> >from commands import getoutput
> >
> >x=getoutput(command)
> >
> >
> >- to your more common and better popens.
> >
> >ie:
> >
> >import popen2
> >
> >(stdOut, stdIn) = popen2.popen4(command)
> >
> >x=stdOut.readlines()
> >
> >- asynchronously if appropriate.
> >
> >How are you running the command at the moment?

>
> .
> .
> .
> Why deprecate commands.getoutput()? Are you merely
> observing that it's applicable in fewer circumstances?


Absolutely so.

Commands.getoutput is simple, quick and useful, just less versatile. Maybe
"not very good" is a pretty vague, almost emotive-sounding way of putting it.
My bad.

Cheers,

Ten

--
There are 10 types of people in this world,
those who understand binary, and those who don't.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting test method names when getting output Hunt Jon Ruby 2 12-18-2008 03:00 PM
Create references to external scipt files from within an external script file Mellow Crow Javascript 6 11-04-2005 01:16 PM
External process output missing Guifre Java 1 05-24-2005 12:12 PM
unresolved external symbol/using an external dll Scott Allen C++ 8 05-02-2004 06:11 PM
Python reading output from a running, external process Brian Elmegaard Python 2 09-10-2003 09:47 PM



Advertisments