diff options
Diffstat (limited to 'blenderkit/upload.py')
-rw-r--r-- | blenderkit/upload.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/blenderkit/upload.py b/blenderkit/upload.py index 3d46c106..b1c4b25c 100644 --- a/blenderkit/upload.py +++ b/blenderkit/upload.py @@ -40,6 +40,7 @@ import tempfile, os, subprocess, json, re import bpy import requests +import threading BLENDERKIT_EXPORT_DATA_FILE = "data.json" @@ -465,13 +466,12 @@ def get_upload_data(self, context, asset_type): return export_data, upload_data, eval_path_computing, eval_path_state, eval_path, props -def verification_status_change(asset_id, state): - user_preferences = bpy.context.preferences.addons['blenderkit'].preferences +def verification_status_change_thread(asset_id, state, api_key): upload_data = { "verificationStatus": state } url = paths.get_api_url() + 'assets/' + str(asset_id) + '/' - headers = utils.get_headers(user_preferences.api_key) + headers = utils.get_headers(api_key) try: r = rerequests.patch(url, json=upload_data, headers=headers, verify=True) # files = files, except requests.exceptions.RequestException as e: @@ -783,7 +783,7 @@ class UploadOperator(Operator): if props.is_private == 'PUBLIC': ui_panels.label_multiline(layout, text='public assets are validated several hours' - ' or days after upload. ', width = 300) + ' or days after upload. ', width=300) def invoke(self, context, event): props = utils.get_upload_props() @@ -794,7 +794,6 @@ class UploadOperator(Operator): return self.execute(context) - class AssetVerificationStatusChange(Operator): """Change verification status""" bl_idname = "object.blenderkit_change_status" @@ -823,8 +822,12 @@ class AssetVerificationStatusChange(Operator): # layout.prop(self, 'state') def execute(self, context): - result = verification_status_change(self.asset_id, self.state) - return result + preferences = bpy.context.preferences.addons['blenderkit'].preferences + + thread = threading.Thread(target=verification_status_change_thread, + args=(self.asset_id, self.state, preferences.api_key)) + thread.start() + return {'FINISHED'} def invoke(self, context, event): print(self.state) |