From c1cdc9cf23976c928e915aa14493981e343e50f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vil=C3=A9m=20Duha?= Date: Mon, 6 Jan 2020 15:36:18 +0100 Subject: BlenderKit: make download more robust --- blenderkit/download.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'blenderkit') diff --git a/blenderkit/download.py b/blenderkit/download.py index c6d22749..296a7639 100644 --- a/blenderkit/download.py +++ b/blenderkit/download.py @@ -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 -- cgit v1.2.3