Re: Getting output from external programs...

Discussion in 'Python' started by Ten, Jun 19, 2006.

  1. Ten

    Ten Guest

    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.
    Ten, Jun 19, 2006
    #1
    1. Advertising

  2. In article <>,
    Ten <> 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?
    Cameron Laird, Jun 19, 2006
    #2
    1. Advertising

  3. Ten

    Ten Guest

    On Monday 19 June 2006 03:44, Cameron Laird wrote:
    > In article <>,
    > Ten <> 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.
    Ten, Jun 19, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    12
    Views:
    1,615
    Dave Thompson
    Jan 10, 2005
  2. Coca
    Replies:
    7
    Views:
    722
    Aidan Grey
    Aug 24, 2004
  3. Replies:
    18
    Views:
    608
    Dave Thompson
    Jan 10, 2005
  4. lone_eagle
    Replies:
    3
    Views:
    622
    psykeedelik
    May 26, 2009
  5. Casey Hawthorne
    Replies:
    14
    Views:
    434
Loading...

Share This Page