This repository has been archived by the owner on Jan 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
b2c421f
commit ae2ffa1
Showing
14 changed files
with
297 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"application_version": "0.1.0", | ||
"application_version": "0.1.2", | ||
"ui_version": "0.8.7" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import hashlib | ||
import os | ||
from functools import partial | ||
|
||
import requests | ||
import json | ||
|
||
from ..constant import UIGF_ITEM_ID_URL, UIGF_MD5_URL | ||
from ..Scripts.Utils.tools import Tools | ||
|
||
utils = Tools() | ||
|
||
|
||
def updateUIGFItemIdList(language, localPath): | ||
if not os.path.exists(f"{utils.getConfigPath()}/metadata/"): | ||
os.mkdir(f"{utils.getConfigPath()}/metadata/") | ||
if not os.path.exists(localPath): | ||
with open(localPath, 'wb') as f: | ||
text = json.dumps(getUIGFItemIdList(language), indent=4, ensure_ascii=False).replace('\r\n', '\n') | ||
f.write(text.encode('utf-8')) | ||
return True | ||
with open(localPath, 'rb') as f: | ||
d = hashlib.md5() | ||
for buf in iter(partial(f.read, 1024), b''): | ||
d.update(buf) | ||
local_md5 = d.hexdigest() | ||
api_md5 = requests.get(UIGF_MD5_URL).json()["chs"] | ||
if not local_md5 == api_md5: | ||
with open(localPath, 'wb') as f: | ||
text = json.dumps(getUIGFItemIdList(language), indent=4, ensure_ascii=False).replace('\r\n', '\n') | ||
f.write(text.encode('utf-8')) | ||
return True | ||
return False | ||
|
||
|
||
def getUIGFItemIdList(language): | ||
return requests.get(UIGF_ITEM_ID_URL.format(lang=language)).json() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import os | ||
import shutil | ||
import subprocess | ||
|
||
import requests | ||
from PySide6.QtWidgets import QApplication | ||
|
||
from ...constant import GITHUB_RELEASE_URL, UPDATE_SCRIPT_MODEL | ||
from ..Utils.tools import Tools | ||
|
||
utils = Tools() | ||
|
||
|
||
def cleanUpdateZip(): | ||
if os.path.exists(f"{utils.workingDir}/temp"): | ||
shutil.rmtree(f"{utils.workingDir}/temp") | ||
os.mkdir(f"{utils.workingDir}/temp") | ||
|
||
|
||
def installUpdate(): | ||
if not os.listdir(f"{utils.workingDir}/temp"): | ||
return | ||
if os.path.exists(f"{utils.workingDir}/asta.py"): | ||
return | ||
with open('temp/update.bat', 'w') as f: | ||
f.write(UPDATE_SCRIPT_MODEL.format(filename=os.listdir(f"{utils.workingDir}/temp")[0])) | ||
|
||
subprocess.Popen( | ||
[ | ||
"start", | ||
"update.bat" | ||
], | ||
cwd='temp', | ||
stdout=subprocess.PIPE, | ||
shell=True | ||
) | ||
QApplication.quit() | ||
|
||
|
||
def findLatestVersion(): | ||
try: | ||
return requests.get(GITHUB_RELEASE_URL).json() | ||
except ValueError: | ||
return None | ||
|
||
|
||
def isNeedUpdate(appVersion): | ||
tag = findLatestVersion() | ||
try: | ||
if not appVersion == tag["tag_name"]: | ||
return tag | ||
except KeyError: | ||
error = requests.get(GITHUB_RELEASE_URL) | ||
if error.json()["message"] == "Not Found": | ||
return None | ||
return "limit", error.headers | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
|
||
import requests | ||
from PySide6.QtCore import Signal, QThread | ||
|
||
from ...constant import GITHUB_RELEASE_URL | ||
|
||
|
||
class UpdateThread(QThread): | ||
trigger = Signal(int, str) | ||
|
||
def __init__(self, info, parent=None): | ||
super(UpdateThread, self).__init__(parent) | ||
self.info = info | ||
|
||
def run(self): | ||
self.trigger.emit(0, "正在从 Github Release 获取更新") | ||
try: | ||
compressed_url = self.info['assets'][0]['browser_download_url'] | ||
file_name = self.info['assets'][0]['name'] | ||
except ConnectionError: | ||
self.trigger.emit(1, "更新失败") | ||
return | ||
except requests.exceptions.SSLError: | ||
self.trigger.emit(1, "更新失败") | ||
return | ||
url = compressed_url | ||
if not os.path.exists('temp'): | ||
os.mkdir('temp') | ||
resp = requests.get(url, stream=True) | ||
count = resp.headers.get('content-length') | ||
with open(f'temp/{file_name}', 'wb') as f: | ||
for chunk in resp.iter_content(chunk_size=2048): | ||
if chunk: | ||
f.write(chunk) | ||
self.trigger.emit(0, f"正在下载: {f.tell()} 字节/{count} 字节") | ||
self.trigger.emit(2, "更新下载完毕") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters