title: How to raise an Exception using the stderr, stdout info of Popen in Python?
body: <p>I have a script which is configurable and some part of it functions on  the systemX correctly while gives an error on the systemY because the command is only known to SystemX.</p>
  
  <pre><code>process = subprocess.Popen (cmd_false, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 
  output, error = process.communicate()
  print "OUTPUT: ", output
  print "ERROR: ", error
  </code></pre>
  
  <p>OUTPUT:  </p>
  
  <blockquote>
    <p>error: 500 - command cmd_false not found</p>
  </blockquote>
  
  <p>ERROR:  </p>
  
  <blockquote>
    <p>(Here is nothing printed) </p>
  </blockquote>
  
  <p>Using a try-except-else mechanism, In spite of encountering this error
  in the try block and expecting the code to jump into except block, it
  end up in the else block.</p>
  
  <p>Btw, I have used the following code snippet but it doesn't raise an error since it returns only the exit status of the child process:</p>
  
  <pre><code>if(process.returncode != 0):
           raise Exception()
  </code></pre>