Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,13 +36,16 @@ for ai_role_en in NAME_DICT.values():
|
|
36 |
pass
|
37 |
if f"{ai_role_en}.zip" not in os.listdir(f"characters_zip"):
|
38 |
destination_file = f"characters_zip/{ai_role_en}.zip"
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
46 |
# wget.download(file_url, destination_file) # 503
|
47 |
destination_folder = f"characters/{ai_role_en}"
|
48 |
with zipfile.ZipFile(destination_file, 'r') as zip_ref:
|
|
|
36 |
pass
|
37 |
if f"{ai_role_en}.zip" not in os.listdir(f"characters_zip"):
|
38 |
destination_file = f"characters_zip/{ai_role_en}.zip"
|
39 |
+
max_retries = 3 # 最大重试次数
|
40 |
+
for attempt in range(1, max_retries+1):
|
41 |
+
response = requests.get(file_url)
|
42 |
+
if response.status_code == 200:
|
43 |
+
with open(destination_file, "wb") as file:
|
44 |
+
file.write(response.content)
|
45 |
+
print(ai_role_en)
|
46 |
+
brek
|
47 |
+
else:
|
48 |
+
print(f"{ai_role_en}第{attempt}次下载失败")
|
49 |
# wget.download(file_url, destination_file) # 503
|
50 |
destination_folder = f"characters/{ai_role_en}"
|
51 |
with zipfile.ZipFile(destination_file, 'r') as zip_ref:
|