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.
This commit is contained in:
parent
8823548db7
commit
9f4246767a
Notes:
blender-bot
2023-02-14 18:35:50 +01:00
Referenced by issue #88901, BlenderKit crashes Blender startup if no active internet connection available
|
@ -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)
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue