chenxiYan commited on
Commit
e7371b4
1 Parent(s): 90f8c19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
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
- response = requests.get(file_url)
40
- if response.status_code == 200:
41
- with open(destination_file, "wb") as file:
42
- file.write(response.content)
43
- print(ai_role_en)
44
- else:
45
- print("download error")
 
 
 
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: