-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from sanmusen214/dev
Global server version update
- Loading branch information
Showing
52 changed files
with
502 additions
and
119 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
日服 | ||
|
||
国际服 | ||
几个月后会实装简易攻略 | ||
|
||
国服 | ||
BUTTON_CAFE_SET_ROOM.png 暂无:国服的咖啡厅切换(版本未到) | ||
礼服日奈的fes也许会把竞技场的跳过战斗文字改动。 | ||
礼服日奈的fes会把社团的入口改动 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
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
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,90 @@ | ||
from nicegui import ui, run | ||
import time | ||
import requests | ||
import os | ||
|
||
async def only_check_version(config): | ||
# 比较访问https://gitee.com/api/v5/repos/sammusen/BAAH/releases/latest和https://api.github.com/repos/sanmusen214/BAAH/releases/latest哪一个快 | ||
urls={ | ||
"gitee":"https://gitee.com/api/v5/repos/sammusen/BAAH/releases/latest", | ||
"github":"https://api.github.com/repos/sanmusen214/BAAH/releases/latest" | ||
} | ||
# 比较访问两个网站的时间,哪个快用哪个 | ||
eachtime = {} | ||
# tag去掉BAAH字样 | ||
eachnewesttag = {} | ||
eachdowloadurl = {} | ||
for key in urls: | ||
nowtime = time.time() | ||
try: | ||
r = await run.io_bound(requests.get, urls[key], timeout=5) | ||
if r.status_code == 200: | ||
eachtime[key] = time.time() - nowtime | ||
data = r.json() | ||
eachnewesttag[key]=data["tag_name"].replace("BAAH", "") | ||
eachdowloadurl[key]=[each["browser_download_url"] for each in data["assets"]] | ||
except: | ||
pass | ||
print(eachtime) | ||
print(eachnewesttag) | ||
print(eachdowloadurl) | ||
resultdict = {} | ||
# 如果两个网站都访问失败 | ||
if len(eachtime) == 0: | ||
ui.notify(config.get_text("notice_fail")) | ||
resultdict["status"] = False | ||
resultdict["msg"] = f'{config.get_text("notice_fail")} Fail to connect Github/Gitee' | ||
return resultdict | ||
# 找到访问时间最短的网站key | ||
fastestkey = min(eachtime, key=eachtime.get) | ||
# 判断是否需要更新 | ||
if config.get_one_version_num(eachnewesttag[fastestkey]) > config.get_one_version_num(): | ||
ui.notify(f'{config.get_text("notice_get_new_version")}: {eachnewesttag[fastestkey]} ({fastestkey})') | ||
resultdict["status"] = True | ||
resultdict["msg"] = f'{config.get_text("notice_get_new_version")}: {eachnewesttag[fastestkey]} ({fastestkey})' | ||
resultdict["urls"] = eachdowloadurl[fastestkey] | ||
else: | ||
ui.notify(config.get_text("notice_no_new_version")) | ||
resultdict["status"] = False | ||
resultdict["msg"] = config.get_text("notice_no_new_version") | ||
return resultdict | ||
|
||
# 检查更新 | ||
async def get_newest_version(config): | ||
"""检查最新版本并下载更新包""" | ||
ui.notify(config.get_text("button_check_version")) | ||
resultdict = await only_check_version(config) | ||
ui.notify(resultdict["msg"]) | ||
if not resultdict["status"]: | ||
return | ||
# 下载 | ||
ui.notify(config.get_text("notice_download_version")) | ||
target_urls = resultdict["urls"] | ||
# 找到urls里面以_update.zip结尾的url | ||
target_url = "" | ||
for each in target_urls: | ||
if each.endswith("_update.zip"): | ||
target_url = each | ||
break | ||
# 下载target_url到当前目录 | ||
if target_url == "": | ||
ui.notify(config.get_text("notice_fail")) | ||
return | ||
# 如果zip文件不在本地就下载 | ||
targetfilename = target_url.split("/")[-1] | ||
if not os.path.exists(targetfilename): | ||
try: | ||
r = await run.io_bound(requests.get, target_url, timeout=10) | ||
|
||
if r.status_code == 200: | ||
with open(targetfilename, "wb") as f: | ||
f.write(r.content) | ||
ui.notify(config.get_text("notice_download_version") + " : " +config.get_text("notice_success")) | ||
else: | ||
ui.notify(config.get_text("notice_download_version") + " : " +config.get_text("notice_fail")) | ||
return | ||
except: | ||
ui.notify(config.get_text("notice_download_version") + " : " +config.get_text("notice_fail")) | ||
return | ||
# 下载完成后解压 | ||
# 将压缩包内BAAH文件夹内的文件解压到当前目录 |
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
Oops, something went wrong.