Merge branch 'main'
This commit is contained in:
@@ -32,6 +32,7 @@ import zipfile
|
||||
import requests
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
@@ -53,7 +54,7 @@ class UpdateProcess(QThread):
|
||||
accomplish = Signal()
|
||||
|
||||
def __init__(
|
||||
self, app_path: str, name: str, main_version: list, updater_version: list
|
||||
self, app_path: Path, name: str, main_version: list, updater_version: list
|
||||
) -> None:
|
||||
super(UpdateProcess, self).__init__()
|
||||
|
||||
@@ -61,10 +62,8 @@ class UpdateProcess(QThread):
|
||||
self.name = name
|
||||
self.main_version = main_version
|
||||
self.updater_version = updater_version
|
||||
self.download_path = os.path.normpath(
|
||||
f"{app_path}/AUTO_MAA_Update.zip"
|
||||
) # 临时下载文件的路径
|
||||
self.version_path = os.path.normpath(f"{app_path}/resources/version.json")
|
||||
self.download_path = app_path / "AUTO_MAA_Update.zip" # 临时下载文件的路径
|
||||
self.version_path = app_path / "resources/version.json"
|
||||
|
||||
def run(self) -> None:
|
||||
|
||||
@@ -185,7 +184,7 @@ class UpdateProcess(QThread):
|
||||
# 主程序更新完成后打开AUTO_MAA
|
||||
if self.name == "AUTO_MAA主程序":
|
||||
subprocess.Popen(
|
||||
os.path.normpath(f"{self.app_path}/AUTO_MAA.exe"),
|
||||
str(self.app_path / "AUTO_MAA.exe"),
|
||||
shell=True,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
)
|
||||
@@ -252,7 +251,7 @@ class UpdateProcess(QThread):
|
||||
class Updater(QObject):
|
||||
|
||||
def __init__(
|
||||
self, app_path: str, name: str, main_version: list, updater_version: list
|
||||
self, app_path: Path, name: str, main_version: list, updater_version: list
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
@@ -260,7 +259,7 @@ class Updater(QObject):
|
||||
self.ui.setWindowTitle("AUTO_MAA更新器")
|
||||
self.ui.resize(700, 70)
|
||||
self.ui.setWindowIcon(
|
||||
QIcon(os.path.normpath(f"{app_path}/resources/icons/AUTO_MAA_Updater.ico"))
|
||||
QIcon(str(app_path / "resources/icons/AUTO_MAA_Updater.ico"))
|
||||
)
|
||||
|
||||
# 创建垂直布局
|
||||
@@ -292,7 +291,7 @@ class Updater(QObject):
|
||||
|
||||
class AUTO_MAA_Updater(QApplication):
|
||||
def __init__(
|
||||
self, app_path: str, name: str, main_version: list, updater_version: list
|
||||
self, app_path: Path, name: str, main_version: list, updater_version: list
|
||||
) -> None:
|
||||
super().__init__()
|
||||
|
||||
@@ -303,14 +302,12 @@ class AUTO_MAA_Updater(QApplication):
|
||||
if __name__ == "__main__":
|
||||
|
||||
# 获取软件自身的路径
|
||||
app_path = os.path.normpath(os.path.dirname(os.path.realpath(sys.argv[0])))
|
||||
app_path = Path.cwd()
|
||||
|
||||
# 从本地版本信息文件获取当前版本信息
|
||||
if os.path.exists(os.path.normpath(f"{app_path}/resources/version.json")):
|
||||
with open(
|
||||
os.path.normpath(f"{app_path}/resources/version.json"),
|
||||
"r",
|
||||
encoding="utf-8",
|
||||
if (app_path / "resources/version.json").exists():
|
||||
with (app_path / "resources/version.json").open(
|
||||
mode="r", encoding="utf-8"
|
||||
) as f:
|
||||
version_current = json.load(f)
|
||||
main_version_current = list(
|
||||
|
||||
@@ -29,19 +29,22 @@ import os
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from app import version_text
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
with open("resources/version.json", "r", encoding="utf-8") as f:
|
||||
root_path = Path.cwd()
|
||||
|
||||
with (root_path / "resources/version.json").open(mode="r", encoding="utf-8") as f:
|
||||
version = json.load(f)
|
||||
|
||||
main_version_numb = list(map(int, version["main_version"].split(".")))
|
||||
updater_version_numb = list(map(int, version["updater_version"].split(".")))
|
||||
|
||||
print("Packaging AUTO-MAA main program ...")
|
||||
print("Packaging AUTO_MAA main program ...")
|
||||
|
||||
result = subprocess.run(
|
||||
f"powershell -Command nuitka --standalone --onefile --mingw64"
|
||||
@@ -52,9 +55,8 @@ if __name__ == "__main__":
|
||||
f" --product-version={version["main_version"]}"
|
||||
f" --file-description='AUTO_MAA Component'"
|
||||
f" --copyright='Copyright © 2024 DLmaster361'"
|
||||
f" --assume-yes-for-downloads --show-progress"
|
||||
f" --output-filename=AUTO_MAA --remove-output"
|
||||
f" main.py",
|
||||
f" --assume-yes-for-downloads --output-filename=AUTO_MAA"
|
||||
f" --remove-output main.py",
|
||||
shell=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
@@ -62,21 +64,20 @@ if __name__ == "__main__":
|
||||
|
||||
print(result.stdout)
|
||||
print(result.stderr)
|
||||
print("AUTO-MAA main program packaging completed !")
|
||||
print("AUTO_MAA main program packaging completed !")
|
||||
|
||||
shutil.copy(os.path.normpath("app/utils/Updater.py"), os.path.normpath("."))
|
||||
shutil.copy(root_path / "app/utils/Updater.py", root_path)
|
||||
|
||||
with open(os.path.normpath("Updater.py"), "r", encoding="utf-8") as f:
|
||||
file_content = f.read()
|
||||
file_content = (root_path / "Updater.py").read_text(encoding="utf-8")
|
||||
|
||||
file_content = file_content.replace(
|
||||
"from .version import version_text", "from app import version_text"
|
||||
(root_path / "Updater.py").write_text(
|
||||
file_content.replace(
|
||||
"from .version import version_text", "from app import version_text"
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
with open(os.path.normpath("Updater.py"), "w", encoding="utf-8") as f:
|
||||
f.write(file_content)
|
||||
|
||||
print("Packaging AUTO-MAA update program ...")
|
||||
print("Packaging AUTO_MAA update program ...")
|
||||
|
||||
result = subprocess.run(
|
||||
f"powershell -Command nuitka --standalone --onefile --mingw64"
|
||||
@@ -84,12 +85,11 @@ if __name__ == "__main__":
|
||||
f" --windows-icon-from-ico=resources\\icons\\AUTO_MAA_Updater.ico"
|
||||
f" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
|
||||
f" --file-version={version["updater_version"]}"
|
||||
f" --product-version={version["updater_version"]}"
|
||||
f" --product-version={version["main_version"]}"
|
||||
f" --file-description='AUTO_MAA Component'"
|
||||
f" --copyright='Copyright © 2024 DLmaster361'"
|
||||
f" --assume-yes-for-downloads --show-progress"
|
||||
f" --output-filename=Updater --remove-output"
|
||||
f" Updater.py",
|
||||
f" --assume-yes-for-downloads --output-filename=Updater"
|
||||
f" --remove-output Updater.py",
|
||||
shell=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
@@ -97,12 +97,11 @@ if __name__ == "__main__":
|
||||
|
||||
print(result.stdout)
|
||||
print(result.stderr)
|
||||
print("AUTO-MAA update program packaging completed !")
|
||||
print("AUTO_MAA update program packaging completed !")
|
||||
|
||||
os.remove(os.path.normpath("Updater.py"))
|
||||
os.remove(root_path / "Updater.py")
|
||||
|
||||
with open("update_info.txt", "w", encoding="utf-8") as f:
|
||||
print(
|
||||
f"{version_text(main_version_numb)}\n{version_text(updater_version_numb)}{version["announcement"]}",
|
||||
file=f,
|
||||
)
|
||||
(root_path / "version_info.txt").write_text(
|
||||
f"{version_text(main_version_numb)}\n{version_text(updater_version_numb)}{version["announcement"]}",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user