chore(build): 为下载资源脚本新增网络超时重试
This commit is contained in:
parent
95b8292e47
commit
78b304f31a
|
@ -8,6 +8,7 @@ import shutil
|
|||
import sqlite3
|
||||
|
||||
import cv2
|
||||
import requests
|
||||
|
||||
sys.path.append(os.path.abspath('./submodules/GkmasObjectManager'))
|
||||
|
||||
|
@ -48,17 +49,27 @@ for row in tqdm.tqdm(cursor.fetchall()):
|
|||
path1 = base_path + f'/{skin_id}_1.png'
|
||||
if asset_id is None:
|
||||
raise ValueError(f"未找到P偶像卡资源:{skin_id} {name}")
|
||||
if not os.path.exists(path0):
|
||||
manifest.download(asset_id0, path=path0, categorize=False)
|
||||
# 转换分辨率 140x188
|
||||
img0 = cv2.imread(path0)
|
||||
assert img0 is not None
|
||||
img0 = cv2.resize(img0, (140, 188), interpolation=cv2.INTER_AREA)
|
||||
cv2.imwrite(path0, img0)
|
||||
if not os.path.exists(path1):
|
||||
manifest.download(asset_id1, path=path1, categorize=False)
|
||||
# 转换分辨率 140x188
|
||||
img1 = cv2.imread(path1)
|
||||
assert img1 is not None
|
||||
img1 = cv2.resize(img1, (140, 188), interpolation=cv2.INTER_AREA)
|
||||
cv2.imwrite(path1, img1)
|
||||
while True:
|
||||
try:
|
||||
if not os.path.exists(path0):
|
||||
manifest.download(asset_id0, path=path0, categorize=False)
|
||||
# 转换分辨率 140x188
|
||||
img0 = cv2.imread(path0)
|
||||
assert img0 is not None
|
||||
img0 = cv2.resize(img0, (140, 188), interpolation=cv2.INTER_AREA)
|
||||
cv2.imwrite(path0, img0)
|
||||
else:
|
||||
print(f'Skipped {path0}')
|
||||
if not os.path.exists(path1):
|
||||
manifest.download(asset_id1, path=path1, categorize=False)
|
||||
# 转换分辨率 140x188
|
||||
img1 = cv2.imread(path1)
|
||||
assert img1 is not None
|
||||
img1 = cv2.resize(img1, (140, 188), interpolation=cv2.INTER_AREA)
|
||||
cv2.imwrite(path1, img1)
|
||||
else:
|
||||
print(f'Skipped {path1}')
|
||||
break
|
||||
except requests.exceptions.ReadTimeout as e:
|
||||
print(f'Network error: {e}')
|
||||
print('Retrying...')
|
||||
|
|
Loading…
Reference in New Issue