Files
workinf_Blender_Wasm/tools/web/native_preferences.py
mes123456 f3e21c6b98
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer,
web workflow engine and protocol, tooling, docs and task records.
Large generated evidence, user-testing archives, build snapshots and
imported test assets remain untracked.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-10 11:18:01 +08:00

23 lines
994 B
Python

"""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