How to separate warnings from errors found in stderr when using Popen.communicate?
<p>I used Python's <a href="https://docs.python.org/3/library/subprocess.html#subprocess.Popen" rel="nofollow"><code>subprocess.Popen</code></a> to execute a command and capture its output:</p>

<pre><code>p = Popen(cmd, stdout=PIPE, stderr=PIPE,shell=True)
stdout, stderr = p.communicate()
</code></pre>

<p>I want to use <code>stderr</code> to tell users when there was an error and exit my script:</p>

<pre><code>if stderr !='':
    return {'error':stderr}
</code></pre>

<p>But now I've found that <code>stderr</code> can contain warnings that could be safely ignored, so my script should not exit, but continue to finish the job.</p>

<p>Is there a way to separate warnings from errors in <code>stderr</code>?</p>