Skip to content

Commit 4bef61c

Browse files
author
Zhao Zuohong
committed
升级依赖;从PySimpleGUI迁移至FreeSimpleGUI;使用requests.Session
1 parent 20b73b4 commit 4bef61c

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

hash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import xxhash
2-
import json
31
import pathlib
42

3+
import xxhash
4+
55

66
def hash(path):
77
p = pathlib.Path(path)

main.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env python3
22

3-
import PySimpleGUI as sg
4-
import platformdirs
5-
import pathlib
63
import json
7-
import requests
8-
import htmllistparse
9-
from hash import hash
4+
import pathlib
105
from multiprocessing.pool import ThreadPool
116

7+
import htmllistparse
8+
import platformdirs
9+
import FreeSimpleGUI as sg
10+
import requests
11+
12+
from hash import hash
1213

1314
default_config = {
1415
"mirror": "https://mower.zhaozuohong.vip",
@@ -35,6 +36,8 @@
3536
conf = default_config
3637

3738

39+
sg.theme("SystemDefaultForReal")
40+
3841
layout = [
3942
[
4043
sg.Text("镜像:", size=(10, 1)),
@@ -76,6 +79,8 @@
7679
enable_close_attempted_event=True,
7780
)
7881

82+
s = requests.Session()
83+
7984

8085
def connect_mirror(mirror):
8186
try:
@@ -98,7 +103,7 @@ def fetch_version_details(mirror, versions):
98103
for v in versions:
99104
url = mirror + v + "/version.json"
100105
try:
101-
r = requests.get(url)
106+
r = s.get(url)
102107
pub_time = r.json()["time"]
103108
except Exception as e:
104109
continue
@@ -166,7 +171,7 @@ def download_single_file(subpath):
166171
mirror += "/"
167172
url = f"{mirror}{version_name}/{subpath}"
168173
try:
169-
r = requests.get(url)
174+
r = s.get(url)
170175
path = pathlib.Path(conf["install_dir"]) / conf["dir_name"] / subpath
171176
path.parent.mkdir(exist_ok=True, parents=True)
172177
with path.open("wb") as f:
@@ -190,7 +195,7 @@ def download_all_files(window):
190195
while True:
191196
event, values = window.read()
192197
conf["mirror"] = values["-mirror-"]
193-
conf["ignore"] = [l for l in values["-ignore-"].splitlines() if l.strip()]
198+
conf["ignore"] = [i for i in values["-ignore-"].splitlines() if i.strip()]
194199
conf["install_dir"] = values["install-dir"]
195200
conf["dir_name"] = values["dir-name"]
196201
conf["pool_limit"] = int(values["pool-limit"])

publish.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env python3
22

33
import json
4-
from hash import hash
54
import pathlib
65
from datetime import datetime
76

7+
from hash import hash
8+
89
try:
910
from zoneinfo import ZoneInfo
1011
except ImportError:

requirements.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
altgraph==0.17.3
2-
beautifulsoup4==4.12.2
3-
certifi==2023.7.22
4-
charset-normalizer==3.2.0
1+
altgraph==0.17.4
2+
backports.zoneinfo==0.2.1
3+
beautifulsoup4==4.12.3
4+
certifi==2024.2.2
5+
charset-normalizer==3.3.2
6+
FreeSimpleGUI==5.1.0
57
fusepy==3.0.1
68
html5lib==1.1
79
htmllistparse==0.6.1
8-
idna==3.4
9-
platformdirs==3.10.0
10-
pyinstaller==5.13.1
11-
pyinstaller-hooks-contrib==2023.7
12-
PySimpleGUI==4.60.5
10+
idna==3.7
11+
importlib_metadata==7.1.0
12+
packaging==24.0
13+
platformdirs==4.2.1
14+
pyinstaller==6.6.0
15+
pyinstaller-hooks-contrib==2024.6
1316
requests==2.31.0
1417
six==1.16.0
15-
soupsieve==2.4.1
16-
urllib3==2.0.4
18+
soupsieve==2.5
19+
urllib3==2.2.1
1720
webencodings==0.5.1
18-
xxhash==3.3.0
21+
xxhash==3.4.1
22+
zipp==3.18.1

0 commit comments

Comments
 (0)