Skip to content

Commit

Permalink
修复缺失的dir_name设置;使用多线程获取版本列表
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhaoZuohong committed May 18, 2024
1 parent 92c9db5 commit eb643b5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"screenshot/**/*",
"adb-buildin/*",
],
"install_dir": "",
"install_dir": "请选择",
"dir_name": "mower",
"pool_limit": 16,
}

Expand All @@ -47,7 +48,7 @@
],
[
sg.vtop(sg.Text("版本:", size=(10, 1))),
sg.Listbox([], key="versions", size=(60, 6)),
sg.Listbox(["按“刷新”按钮获取版本列表"], key="versions", size=(60, 6)),
],
[
sg.Text("安装位置:", size=(10, 1)),
Expand Down Expand Up @@ -100,21 +101,27 @@ def connect_mirror(mirror):
def fetch_version_details(mirror, versions):
if not mirror.endswith("/"):
mirror += "/"

result = []
for v in versions:

def fetch_single_version_detail(v):
url = mirror + v + "/version.json"
try:
r = s.get(url)
pub_time = r.json()["time"]
except Exception:
continue
result.append(
{
"version": v,
"display_name": f"{v} ({pub_time})",
"hash": r.json()["hash"],
}
)
return None
return {
"version": v,
"display_name": f"{v} ({pub_time})",
"hash": r.json()["hash"],
}

with ThreadPool(conf["pool_limit"]) as pool:
for info in pool.imap(fetch_single_version_detail, versions):
if info:
result.append(info)

return result


Expand Down

0 comments on commit eb643b5

Please sign in to comment.