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:
authorVilém Duha <vilda.novak@gmail.com>2021-03-22 00:00:34 +0300
committerVilém Duha <vilda.novak@gmail.com>2021-03-22 00:00:34 +0300
commit9f4246767a00f227b59fce142851dee3d9deeff1 (patch)
tree1ec3b9a0a2c791c88fbae23101f98dd8fe15ef0b /blenderkit
parent8823548db714f869be82ab8c78d33aef24c0d981 (diff)
BlenderKit: fix upload - asset base id wasn't written to upload files.
This sadly includes all uploads from 2.92. Also attempt to fix crash coming from the requests module - guarding the requests call with try statement seems to fix the problem.
Diffstat (limited to 'blenderkit')
-rw-r--r--blenderkit/rerequests.py5
-rw-r--r--blenderkit/upload.py18
-rw-r--r--blenderkit/upload_bg.py4
3 files changed, 13 insertions, 14 deletions
diff --git a/blenderkit/rerequests.py b/blenderkit/rerequests.py
index 75d8fa27..6a2659c2 100644
--- a/blenderkit/rerequests.py
+++ b/blenderkit/rerequests.py
@@ -32,7 +32,10 @@ def rerequest(method, url, **kwargs):
immediate = kwargs['immediate']
kwargs.pop('immediate')
# first normal attempt
- response = requests.request(method, url, **kwargs)
+ try:
+ response = requests.request(method, url, **kwargs)
+ except:
+ return rerequest(method, url, **kwargs)
bk_logger.debug(url+ str( kwargs))
bk_logger.debug(response.status_code)
diff --git a/blenderkit/upload.py b/blenderkit/upload.py
index 495f588c..4f9ee1ab 100644
--- a/blenderkit/upload.py
+++ b/blenderkit/upload.py
@@ -72,7 +72,7 @@ def add_version(data):
def write_to_report(props, text):
- props.report = props.report + ' - '+ text + '\n\n'
+ props.report = props.report + ' - ' + text + '\n\n'
def check_missing_data_model(props):
@@ -857,7 +857,7 @@ class Uploader(threading.Thread):
return self._stop_event.is_set()
def send_message(self, message):
- message = str(message).replace("'","")
+ message = str(message).replace("'", "")
# this adds a UI report but also writes above the upload panel fields.
tasks_queue.add_task((ui.add_report, (message,)))
@@ -944,6 +944,8 @@ class Uploader(threading.Thread):
estring = f"{self.export_data['eval_path']}.blenderkit.id = '{rj['id']}'"
tasks_queue.add_task((exec, (estring,)))
# after that, the user's file needs to be saved to save the
+ # estring = f"bpy.ops.wm.save_as_mainfile(filepath={self.export_data['source_filepath']}, compress=False, copy=True)"
+ # tasks_queue.add_task((exec, (estring,)))
self.upload_data['assetBaseId'] = self.export_data['assetBaseId']
self.upload_data['id'] = self.export_data['id']
@@ -969,16 +971,6 @@ class Uploader(threading.Thread):
with open(datafile, 'w', encoding='utf-8') as s:
json.dump(data, s, ensure_ascii=False, indent=4)
- # non waiting method - not useful here..
- # proc = subprocess.Popen([
- # binary_path,
- # "--background",
- # "-noaudio",
- # clean_file_path,
- # "--python", os.path.join(script_path, "upload_bg.py"),
- # "--", datafile # ,filepath, tempdir
- # ], bufsize=5000, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
- # tasks_queue.add_task((ui.add_report, ('preparing scene - running blender instance',)))
self.send_message('preparing scene - running blender instance')
proc = subprocess.run([
@@ -1224,7 +1216,7 @@ class UploadOperator(Operator):
'- Check if it snaps correctly to surfaces\n'
'- Check if it has all textures and renders as expected\n'
'- Check if it has correct size in world units (for models)'
- , width=400)
+ , width=400)
else:
utils.label_multiline(layout, text='You marked the asset as public.\n'
'This means it will be validated by our team.\n\n'
diff --git a/blenderkit/upload_bg.py b/blenderkit/upload_bg.py
index cc64f470..3307a72a 100644
--- a/blenderkit/upload_bg.py
+++ b/blenderkit/upload_bg.py
@@ -167,6 +167,10 @@ if __name__ == "__main__":
bpy.ops.file.pack_all()
main_source.blenderkit.uploading = False
+ #write ID here.
+ main_source.blenderkit.asset_base_id = export_data['assetBaseId']
+ main_source.blenderkit.id = export_data['id']
+
fpath = os.path.join(export_data['temp_dir'], upload_data['assetBaseId'] + '.blend')
bpy.ops.wm.save_as_mainfile(filepath=fpath, compress=True, copy=False)