Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVilem Duha <vilem.duha@gmail.com>2019-06-17 01:10:54 +0300
committerVilem Duha <vilem.duha@gmail.com>2019-06-17 17:14:11 +0300
commit4fff91efbaf10360e0618338c8cb6ce4795b8f5f (patch)
tree3ff1d9bbccbd8e890877b5f0dc622619b782ae86 /blenderkit/upload.py
parent8009a267b8bb7a5ab020bc72f36e2bfa0500e680 (diff)
BlenderKit: better reporting for failed uploads
bugfix - only fetch server data when not in background(fetching api key during upload procedure is a very bad idea) updatea oauth script. Mention Petr Dlouhy as co-author Temporarily enable Api key field also with oauth on.
Diffstat (limited to 'blenderkit/upload.py')
-rw-r--r--blenderkit/upload.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/blenderkit/upload.py b/blenderkit/upload.py
index 49aced95..31585a4f 100644
--- a/blenderkit/upload.py
+++ b/blenderkit/upload.py
@@ -28,10 +28,12 @@ if "bpy" in locals():
version_checker = reload(version_checker)
search = reload(search)
ui_panels = reload(ui_panels)
+ ui = reload(ui)
overrides = reload(overrides)
+ colors = reload(colors)
else:
- from blenderkit import asset_inspector, paths, utils, bg_blender, autothumb, version_checker, search, ui_panels, \
- overrides
+ from blenderkit import asset_inspector, paths, utils, bg_blender, autothumb, version_checker, search, ui_panels, ui, \
+ overrides, colors
import tempfile, os, subprocess, json, re
@@ -527,7 +529,7 @@ def check_storage_quota(props):
def auto_fix(asset_type=''):
- #this applies various procedures to ensure coherency in the database.
+ # this applies various procedures to ensure coherency in the database.
asset = utils.get_active_asset()
props = utils.get_upload_props()
if asset_type == 'MATERIAL':
@@ -546,12 +548,11 @@ def start_upload(self, context, asset_type, as_new, metadata_only):
location = get_upload_location(props)
props.upload_state = 'preparing upload'
- auto_fix(asset_type = asset_type)
+ auto_fix(asset_type=asset_type)
# do this for fixing long tags in some upload cases
props.tags = props.tags[:]
-
props.name = props.name.strip()
# TODO move this to separate function
# check for missing metadata
@@ -646,15 +647,18 @@ def start_upload(self, context, asset_type, as_new, metadata_only):
return {'FINISHED'}
try:
rj = r.json()
+ utils.pprint(rj)
+ if r.status_code != 200:
+ if r.status_code == 401:
+ ui.add_report(r.detail, 5, colors.RED)
+ return {'CANCELLED'}
if props.asset_base_id == '':
props.asset_base_id = rj['assetBaseId']
props.id = rj['id']
-
upload_data['assetBaseId'] = props.asset_base_id
upload_data['id'] = props.id
bpy.ops.wm.save_mainfile()
- # fa
props.uploading = True
# save a copy of actual scene but don't interfere with the users models
bpy.ops.wm.save_as_mainfile(filepath=source_filepath, compress=False, copy=True)
@@ -677,6 +681,7 @@ def start_upload(self, context, asset_type, as_new, metadata_only):
except Exception as e:
props.upload_state = str(e)
props.uploading = False
+ print(e)
return {'CANCELLED'}
return {'FINISHED'}
@@ -751,7 +756,7 @@ class ModelUploadOperator(Operator):
layout.label(text="For updates of thumbnail or model use reupload.")
if props.is_private == 'PUBLIC':
- ui_panels.label_multiline(layout, text='Since this version (1.0.24), '
+ ui_panels.label_multiline(layout, text='Since version 1.0.24: '
'PUBLIC ASSETS ARE VALIDATED AUTOMATICALLY '
' after upload. '
'Click Ok to proceed.')