"""Load the Web Blender profile without touching the desktop user's config.""" from pathlib import Path import bpy def load_preferences(root): if (root / 'config' / 'userpref.blend').is_file(): state = bpy.ops.wm.read_userpref('EXEC_DEFAULT') if 'FINISHED' not in state: raise RuntimeError('PREFERENCES_LOAD_FAILED') # Persistence is an explicit Web session command, not shutdown of a temporary job. bpy.context.preferences.use_preferences_save = False def save_preferences(root, sequence): state = bpy.ops.wm.save_userpref('EXEC_DEFAULT') if 'FINISHED' not in state: raise RuntimeError('PREFERENCES_SAVE_FAILED') source = Path(bpy.utils.user_resource('CONFIG')) / 'userpref.blend' if not source.is_file() or source.stat().st_size > 16 * 1024 * 1024: raise RuntimeError('PREFERENCES_SAVE_OUTPUT_INVALID') destination = root / f'preferences-{sequence:08d}.blend' destination.write_bytes(source.read_bytes()) return destination