title: Using Popen to output everything in one stream
body: <p>I'm having some trouble trying to get subprocess to do what I want it to do. I have a test tool that takes an input file. testtool.exe -f  and produces output like this when run in a command prompt. </p>
  
  <pre><code>12:30:46 INFO  Output- Processing arguments
  12:30:46 INFO  Output- Arguments ok
  12:30:46 INFO  Output- Doing something
  12:30:46 INFO  Output- More Stuff
  12:30:03 ERROR Output- Error found
  12:30:03 INFO  Output- Finished
  12:30:03 INFO  Output- Exiting
  </code></pre>
  
  <p>So i'm trying to use subprocess to run this tool in python Python 3.4.3. For example...</p>
  
  <pre><code>proc = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True).communicate()[0].decode('utf-8')
  for i in proc.splitlines():
      print("&gt; {0}".format(i))
  </code></pre>
  
  <p>Unfortunately the output does not contain the 'ERROR' line. I want to take the output exactly as i'd get it from a command prompt because I need to do extra verification on it. Such as how many error lines appear, where they appear in the output. So splitting ERROR and INFO lines into different streams doesn't suit me. </p>
  
  <pre><code>&gt; 12:30:46 INFO  Output- Processing arguments
  &gt; 12:30:46 INFO  Output- Arguments ok
  &gt; 12:30:46 INFO  Output- Doing something
  &gt; 12:30:46 INFO  Output- More Stuff
  &gt; 12:30:03 INFO  Output- Finished
  &gt; 12:30:03 INFO  Output- Exiting
  </code></pre>
  
  <p>I've also tried</p>
  
  <pre><code>proc = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=STDOUT, shell=True).communicate()[0].decode('utf-8')
  </code></pre>
  
  <p>And this is my latest reincarnation..</p>
  
  <pre><code>    proc = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
      proc_data = proc.communicate()
  
      for i in proc_data[0].splitlines():
          print ("INFO&gt; {0}".format(i))
  
      for i in proc_data[1].splitlines():
          print ("ERROR&gt; {0}".format(i))
  </code></pre>
  
  <p>Also, the ERROR line never appears. Its like its being lost somewhere? </p>