新增更新程序源码和构建脚本
This commit is contained in:
1
build_upd.bat
Normal file
1
build_upd.bat
Normal file
@ -0,0 +1 @@
|
||||
.\.venv\Scripts\pyinstaller -F -w -i icon.ico update.py
|
3
nflmusic/.idea/.gitignore
generated
vendored
Normal file
3
nflmusic/.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
40
update.py
Normal file
40
update.py
Normal file
@ -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()
|
Reference in New Issue
Block a user