Skip to content

Commit eb643b5

Browse files
author
Zhao Zuohong
committed
修复缺失的dir_name设置;使用多线程获取版本列表
1 parent 92c9db5 commit eb643b5

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

main.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"screenshot/**/*",
2323
"adb-buildin/*",
2424
],
25-
"install_dir": "",
25+
"install_dir": "请选择",
26+
"dir_name": "mower",
2627
"pool_limit": 16,
2728
}
2829

@@ -47,7 +48,7 @@
4748
],
4849
[
4950
sg.vtop(sg.Text("版本:", size=(10, 1))),
50-
sg.Listbox([], key="versions", size=(60, 6)),
51+
sg.Listbox(["按“刷新”按钮获取版本列表"], key="versions", size=(60, 6)),
5152
],
5253
[
5354
sg.Text("安装位置:", size=(10, 1)),
@@ -100,21 +101,27 @@ def connect_mirror(mirror):
100101
def fetch_version_details(mirror, versions):
101102
if not mirror.endswith("/"):
102103
mirror += "/"
104+
103105
result = []
104-
for v in versions:
106+
107+
def fetch_single_version_detail(v):
105108
url = mirror + v + "/version.json"
106109
try:
107110
r = s.get(url)
108111
pub_time = r.json()["time"]
109112
except Exception:
110-
continue
111-
result.append(
112-
{
113-
"version": v,
114-
"display_name": f"{v} ({pub_time})",
115-
"hash": r.json()["hash"],
116-
}
117-
)
113+
return None
114+
return {
115+
"version": v,
116+
"display_name": f"{v} ({pub_time})",
117+
"hash": r.json()["hash"],
118+
}
119+
120+
with ThreadPool(conf["pool_limit"]) as pool:
121+
for info in pool.imap(fetch_single_version_detail, versions):
122+
if info:
123+
result.append(info)
124+
118125
return result
119126

120127

0 commit comments

Comments
 (0)