diff options
Diffstat (limited to 'blenderkit/upload.py')
-rw-r--r-- | blenderkit/upload.py | 21 |
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.') |