BlenderKit: make download more robust

This commit is contained in:
Vilém Duha 2020-01-06 15:36:18 +01:00
parent 9b03ef289b
commit c1cdc9cf23
1 changed files with 10 additions and 8 deletions

View File

@ -741,17 +741,16 @@ def get_download_url(asset_data, scene_id, api_key, tcom=None):
data = {
'scene_uuid': scene_id
}
r = None
try:
r = rerequests.get(asset_data['download_url'], params=data, headers=headers)
except Exception as e:
print(e)
if tcom is not None:
tcom.error = True
if r == None:
tcom.report = 'Connection Error'
tcom.error = True
if tcom is not None:
tcom.report = 'Connection Error'
tcom.error = True
return 'Connection Error'
if r.status_code < 400:
@ -763,14 +762,17 @@ def get_download_url(asset_data, scene_id, api_key, tcom=None):
if r.status_code == 403:
r = 'You need Full plan to get this item.'
tcom.report = r
r1 = 'All materials and brushes are available for free. Only users registered to Standard plan can use all models.'
tasks_queue.add_task((ui.add_report, (r1, 5, colors.RED)))
tcom.error = True
if tcom is not None:
tcom.report = r
tcom.error = True
elif r.status_code >= 500:
tcom.report = 'Server error'
tcom.error = True
utils.p(r.text)
if tcom is not None:
tcom.report = 'Server error'
tcom.error = True
return False