Topic: Help with Python subprocess.Popen

I'm trying to write a GUI for the latest handbrake command line DVD ripper and I'm having and issue with using subprocess.Popen to get the titles of the DVD.

This code works, if I issue the command ls it will grab the return and add each file to the Tree as a new node.

   cmd = 'ls'
    rtn = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE).stdout
    title = rtn.read().split('\n')
    for line in title:
      self.Tree.AppendItem(self.rootID,line)

But this code does not, it seems to me that the cmd just is returning too much, it ends up just returning ''
even though if you run the cmd line in a term you'll will get lots of information

   cmd = '/usr/local/bin/handbrake -i /dev/acd0 -t 0'
    rtn = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE).stdout
    title = rtn.read().split('\n')
    for line in title:
      self.Tree.AppendItem(self.rootID,line)

Just wondering if anyone here has any ideas since no one on the Python list responded for over a week now...

"An educator never says what he himself thinks, but only that which he thinks it is good for those whom he is educating to hear."
-Nietzsche

Re: Help with Python subprocess.Popen

If I understand what you are doing correctly, I think this might do what you want...

import commands

rtn = commands.getoutput('ls')

sounds like a cool project.

brian

Re: Help with Python subprocess.Popen

Thanks!

This way worked great. As soon as I get something working I'll make a posting on this board.

"An educator never says what he himself thinks, but only that which he thinks it is good for those whom he is educating to hear."
-Nietzsche