title: How to check if a shell command is over in Python
body: <p>Let's say that I have this simple line in python:</p>
  
  <pre><code>os.system("sudo apt-get update")
  </code></pre>
  
  <p>of course, apt-get will take some time untill it's finished, how can I check in python if the command had finished or not yet?</p>
  
  <p>Edit: this is the code with Popen:</p>
  
  <pre><code>     os.environ['packagename'] = entry.get_text()
       process = Popen(['dpkg-repack', '$packagename'])
       if process.poll() is None:
         print "It still working.."
       else:
         print "It finished"
  </code></pre>
  
  <p>Now the problem is, it never print "It finished" even when it really finish.</p>