title: Running command with os.popen with sudo in python
body: <p>I have a command <code>/usr/bin/virsh dumpxml &lt;UUID&gt;</code> that I need to run inside of a python program, the thing is that the command needs to run like <code>sudo -u &lt;user&gt; sudo /usr/bin/virsh dumpxml &lt;UUID&gt;</code>, I try to call it with the following code:</p>
  
  <pre class="lang-py prettyprint-override"><code>cmd = "sudo -u &lt;user&gt; sudo /usr/bin/virsh dumpxml %s" % uuid
  data = os.popen(cmd).read()
  ...
  </code></pre>
  
  <p>But I'm getting an error message indicating that the domain is not found, but, if I run the same command from the bash, it works fine.</p>
  
  <p>The <code>/usr/bin/virsh dumpxml</code> command is inside the /etc/sudoers.d/</p>
  
  <p>Also, I need to run with the second '<strong>sudo</strong>' because if not, it won't work</p>
  
  <p>Any ideas?</p>