title: Piping output of subprocess.call to progress bar
body: <p>I'm using growisofs to burn an iso through my Python application. I have two classes in two different files; GUI() (main.py) and Boxblaze() (core.py). GUI() builds the window and handles all the events and stuff, and Boxblaze() has all the methods that GUI() calls. </p>
  
  <p>Now when the user has selected the device to burn with, and the file to be burned, I need to call a method that calls the following command:`</p>
  
  <pre><code>growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2 -Z /burner/device=/full/path/to.iso
  </code></pre>
  
  <p>This command should give an output similar to this:</p>
  
  <pre><code>Executing 'builtin_dd if=/home/nevon/games/Xbox 360 isos/The Godfather 2/alls-tgod2.iso of=/dev/scd0 obs=32k seek=0'
  /dev/scd0: "Current Write Speed" is 2.5x1352KBps.
  #more of the lines below, indicating progress.
  7798128640/7835492352 (99.5%) @3.8x, remaining 0:06 RBU 100.0% UBU  99.8%
  7815495680/7835492352 (99.7%) @3.8x, remaining 0:03 RBU  59.7% UBU  99.8%
  7832862720/7835492352 (100.0%) @3.8x, remaining 0:00 RBU   7.9% UBU  99.8%
  builtin_dd: 3825936*2KB out @ average 3.9x1352KBps
  /dev/burner: flushing cache
  /dev/burner: closing track
  /dev/burner: closing disc
  </code></pre>
  
  <p>This command is run in a method called burn() in Boxblaze(). It looks simply like this:</p>
  
  <pre><code>def burn(self, file, device):
      subprocess.call(["growisofs", '-dry-run', "-use-the-force-luke=dao", "-use-the-force-luke=break:1913760", "-dvd-compat", "-speed=2", "-Z",  device +'='+ file])
  </code></pre>
  
  <p><strong>Now my questions are the following:</strong></p>
  
  <ol>
  <li><p>How can I get the progress from the output (the percentage in brackets) and have my progress bar be set to "follow" that progress? My progress bar is called in the GUI() class, as such: </p>
  
  <p>get = builder.get_object</p>
  
  <p>self.progress_window = get("progressWindow")</p>
  
  <p>self.progressbar = get("progressbar")</p></li>
  <li><p>Do I have to run this command in a separate thread in order for the GUI to remain responsive (so that I can update the progress bar and allow the user to cancel the burn if they want to)? If so, how can I do that and still be able to pass the progress to the progress bar?</p></li>
  </ol>
  
  <hr>
  
  <p>The full code is available <a href="http://www.launchpad.net/boxblaze" rel="nofollow noreferrer">on Launchpad</a> if you are interested. If you have bazaar installed, just run:</p>
  
  <pre><code>bzr branch lp:boxblaze
  </code></pre>
  
  <p>Oh, and in case you were wondering, this application is only meant to work in Linux - so don't worry about cross-platform compatibility. </p>