Update program: overwrite files?
<p>I'm developing a software and I want, for several reasons, to develop my own auto-update feature. The program is a full GUI, written with PyQt, and uses icons, data files, etc. It will be frozen with cx_freeze or pyinstaller.</p>

<p>The auto-update part will download the new version (a zip) on a remote server. Then, it gets complicated:</p>

<p>The software is running, and has downloaded the new version. What does it do with the new version ? Can the software extract the files from the zip, and overwrite the files of the running version ?</p>

<p>Or should I store the new version aside, quit the running version, and somehow use the new version ? If so, how do I do the exchange between the old and new version ?</p>

<p>EDIT:</p>

<p>Here is for example the <code>closeEvent</code> method of my class QMainWindow:</p>

<pre><code>def closeEvent(self, event):

    """Method to perform actions before exiting.
    Allows to save the prefs in a file"""

    ...Do some stuff...

    QtGui.qApp.quit()

    self.logger.info("Closing the program")
</code></pre>

<p>Can I use this method to perform the exchange ?</p>

<p>This is a similar <a href="http://stackoverflow.com/questions/16549331/pyqt-application-performing-updates">question</a> to yours and the accepted answer says:</p>

<blockquote>
  <p>After downloading the installer for the newer version, you can use
  <a href="http://docs.python.org/2/library/atexit.html#atexit.register" rel="nofollow"><code>atexit.register()</code></a> with <a href="http://docs.python.org/3.3/library/os#os.execl" rel="nofollow"><code>os.exec*()</code></a> to run the installer,
  e.g. <code>atexit.register(os.execl, "installer.exe", "installer.exe")</code>.
  This will make the installer start when the application is about to
  exit. The application will immediately exit after the <code>os.exec*()</code>
  call, so no race condition will occur.</p>
</blockquote>

<p>Looks like a good solution for your use-case</p>

python pyqt auto-update