title: python calling shell command (open) and waiting for command finish. How to get a signal once the job has finished?
body: <p>I'm using an app called shoebox.app with can split a psd file to several png files.
  The app provides a CMD interface and I tried it in termial which works fine:</p>
  
  <pre><code>open /Applications/ShoeBox.app --args \"files=xxx.psd\"
  </code></pre>
  
  <p>and now I want to write a python script to do the work:</p>
  
  <pre><code>import os
  if __name__ == '__main__':
      CMD = "open /Applications/ShoeBox.app --args \"files=xxx.psd\""
      os.system(CMD)
  </code></pre>
  
  <p>this also works fine.</p>
  
  <p>Now what I want to do something <strong>after</strong> the "spliting psd to png job" finishes:</p>
  
  <pre><code>import os
  if __name__ == '__main__':
      CMD = "open /Applications/ShoeBox.app --args \"files=xxx.psd\""
      os.system(CMD)
  
      do_something_to_pngs_func()
  </code></pre>
  
  <p>The problem is the "split job" takes several seconds and I need to wait till it ends and then call my
  <code>do_something_to_pngs_func</code> function.</p>
  
  <p><strong>But, how could I know the <code>os.system(CMD)</code> actually ends?</strong></p>
  
  <p>Now my interim solution is to add a "<code>time.sleep(10)</code>" before calling my function, but that's not the best solution, of course.</p>
  
  <p>Any advice will be appreciated, thanks :)</p>