From 33694b45185a502ccf409f571801192d1e8eb83d Mon Sep 17 00:00:00 2001 From: NFL_jiancx <1678594309@qq.com> Date: Thu, 23 Jan 2025 19:24:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9B=B4=E6=96=B0=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=BA=90=E7=A0=81=E5=92=8C=E6=9E=84=E5=BB=BA=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build_upd.bat | 1 + nflmusic/.idea/.gitignore | 3 +++ update.py | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 build_upd.bat create mode 100644 nflmusic/.idea/.gitignore create mode 100644 update.py diff --git a/build_upd.bat b/build_upd.bat new file mode 100644 index 0000000..f3f5a4a --- /dev/null +++ b/build_upd.bat @@ -0,0 +1 @@ +.\.venv\Scripts\pyinstaller -F -w -i icon.ico update.py \ No newline at end of file diff --git a/nflmusic/.idea/.gitignore b/nflmusic/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/nflmusic/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/update.py b/update.py new file mode 100644 index 0000000..a68a017 --- /dev/null +++ b/update.py @@ -0,0 +1,40 @@ +import os +import subprocess +import threading +import time + +appdata = os.getenv("APPDATA") +update_path = appdata + "/.NFLmusic/update/" + +with open(f"{update_path}file_path", "r") as f: + data = f.read() + version = data.split("\n")[0] + path = data.split("\n")[1] + +source_file = f"{update_path}NFLmusicv{version}.exe" + +new_path = path.rsplit("\\", 1)[0] + +while True: + try: + with open(source_file, "rb") as f: + content = f.read() + with open(path, "wb") as f: + f.write(content) + break + except: + pass + time.sleep(0.05) + +try: + os.rename(path, f"NFLmusicv{version}.exe") +except: + pass +os.remove(source_file) + + +def run_NFLmusic(): + subprocess.Popen(new_path + f"/NFLmusicv{version}.exe") + + +run_NFLmusic()