diff options
author | Vilém Duha <vilda.novak@gmail.com> | 2020-01-06 17:36:18 +0300 |
---|---|---|
committer | Vilém Duha <vilda.novak@gmail.com> | 2020-01-07 13:43:44 +0300 |
commit | c1cdc9cf23976c928e915aa14493981e343e50f6 (patch) | |
tree | 75d21a0af07fa13b40c871343fe78f43d9cf46c6 /blenderkit/download.py | |
parent | 9b03ef289bf69679c48a45e2c65125a5b88d6f8b (diff) |
BlenderKit: make download more robust
Diffstat (limited to 'blenderkit/download.py')
-rw-r--r-- | blenderkit/download.py | 18 |
1 files changed, 10 insertions, 8 deletions
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 |