如何更新使用Python制造的软件?

发布于 2025-01-28 06:41:31 字数 424 浏览 5 评论 0原文

免责声明:我仍在学习,是Python的新手,所以我对Python的了解少于大多数编码器。

我正在制作一个简单的桌面应用程序,并且已经在 .exe .exe 中文件格式。

如何将更新发送给拥有该应用程序的人?

我在想,当用户打开文件时,我是否可以从网站(例如Pastebin)加载一些GitHub代码或原始代码,以便每次他们一次打开我的应用程序,他们具有最新版本。我基本上是从GitHub存储库和Python代码中对其进行更新的,它只会从Github加载文件,因此我可以像大多数桌面应用程序一样进行更改(Steam,Spotify,Microsoft,Microsoft Apps,Adobe Apps等)。我可以进一步解释我是否没有意义。

这是可能的吗?

Disclaimer: I am still learning and am new to python so I have less knowledge of python than most coders.

I am making a simple desktop app and it is already in .exe file format.

How can I send updates to people who have the app?

I was thinking if I could load some GitHub code or raw code from a website (like Pastebin) when a user opens the file so that every time they open my app they have the latest version of it. I am basically updating it from the GitHub repository and in the python code, it only loads the file from GitHub so I can make changes like most desktop apps (Steam, Spotify, Microsoft Apps, Adobe apps etc). I can explain further if I don't make sense.

Is this possible? If so how can I do this? Are there any ways?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

反差帅 2025-02-04 06:41:31

您将必须拥有一个不同的网站,上面有当前版本。我通常要更新的事情是我在某个地方存储了一个.html文件(例如Dropbox),并且程序检查是否为.html的内容(文件中没有实际的HTML,只有版本号)与其版本字符串匹配,以及是否匹配。不,它将HTML文件中的版本编号附加到字符串(EG example.com/version-1.0.0,1.0.0是已添加的版本)并下载。

您可以使用urllib进行HTML请求,并使用请求下载文件。

import urllib.request
import requests
import time

currentVersion = "1.0.0"
URL = urllib.request.urlopen('https://example.com/yourapp/version.html')

data = URL.read()
if (data == currentVersion):
    print("App is up to date!")
else:
    print("App is not up to date! App is on version " + currentVersion + " but could be on version " + data + "!")
    print("Downloading new version now!")
    newVersion = requests.get("https://github.com/yourapp/app-"+data+".exe")
    open("app.exe", "wb").write(newVersion.content)
    print("New version downloaded, restarting in 5 seconds!")
    time.sleep(5)
    quit()

You would have to have a different website that has the current version on it. What I usually do for updating is I have a .html file stored somewhere (e.g. DropBox) and the program checks if that .html's contents (no actual HTML in the file, just the version number) match with its version string, and if it doesn't, it appends the version number in the HTML file to a string (e.g. example.com/version-1.0.0, 1.0.0 being the version appended) and downloads that.

You can do HTML requests with urllib and download files with requests.

import urllib.request
import requests
import time

currentVersion = "1.0.0"
URL = urllib.request.urlopen('https://example.com/yourapp/version.html')

data = URL.read()
if (data == currentVersion):
    print("App is up to date!")
else:
    print("App is not up to date! App is on version " + currentVersion + " but could be on version " + data + "!")
    print("Downloading new version now!")
    newVersion = requests.get("https://github.com/yourapp/app-"+data+".exe")
    open("app.exe", "wb").write(newVersion.content)
    print("New version downloaded, restarting in 5 seconds!")
    time.sleep(5)
    quit()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文