pyqt 应用程序执行更新 [英] pyqt application performing updates
问题描述
我有一个 PyQt
应用程序准备发布.一切都很好,我只有一件事要结束.我喜欢自动更新的软件:
I have a PyQt
application ready to release. Everything works pretty well and I only have one more thing to wrap up. I love software that updates itself:
- 检查新版本的网址;
- 发现新版本;
- 通知用户更新(点击)→ 更新.
问题是我不知道如何执行此更新.我检查,找到新版本,下载它,然后我必须关闭应用程序并执行新版本的安装程序.如果我关闭它,那么我将无法执行任何其他操作,如果我执行安装程序,我将无法关闭该应用程序.
The problem is that I don't know how to perform this update. I check, I find new version, I download it and then I must close the application and execute the installer of the new version. If I close it then I can't execute anything else, If I execute the installer I can't close the application.
根据一些用户的选择,我的程序还下载并安装了一些需要同样事情的第三方软件:安装程序前关闭,安装程序后重新启动.
Based on some user choices my program also downloads and installs some third party software which needs the same thing: close before install program, restart after install program.
推荐答案
下载新版本的安装程序后,您可以使用 atexit.register()
和 os.exec*()
运行安装程序,例如atexit.register(os.execl, "installer.exe", "installer.exe")
.这将使安装程序在应用程序即将退出时启动.应用程序会在 os.exec*()
调用后立即退出,因此不会发生竞争条件.
After downloading the installer for the newer version, you can use atexit.register()
with os.exec*()
to run the installer, e.g. atexit.register(os.execl, "installer.exe", "installer.exe")
. This will make the installer start when the application is about to exit. The application will immediately exit after the os.exec*()
call, so no race condition will occur.
这篇关于pyqt 应用程序执行更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!