From e16856781858753dffd8287dc5a54d39d328c394 Mon Sep 17 00:00:00 2001 From: Strike Digital <59890307+strike-digital@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:04:55 +0100 Subject: [PATCH] test changes --- pythonFiles/include/blender_vscode/environment.py | 10 +++++++++- pythonFiles/include/blender_vscode/load_addons.py | 13 ++++++++++++- src/utils.ts | 8 +++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pythonFiles/include/blender_vscode/environment.py b/pythonFiles/include/blender_vscode/environment.py index 7d4e323..a3f3750 100644 --- a/pythonFiles/include/blender_vscode/environment.py +++ b/pythonFiles/include/blender_vscode/environment.py @@ -16,5 +16,13 @@ version = bpy.app.version scripts_folder = blender_path.parent / f"{version[0]}.{version[1]}" / "scripts" -user_addon_directory = Path(bpy.utils.user_resource('SCRIPTS', path="addons")) + + +def get_user_addon_directory(source_path: Path): + if version >= (4, 2, 0) and next(source_path.glob("blender_manifest.toml"), None): + return Path(bpy.utils.user_resource("EXTENSIONS", path="user_default")) + else: + return Path(bpy.utils.user_resource('SCRIPTS', path="addons")) + + addon_directories = tuple(map(Path, addon_utils.paths())) diff --git a/pythonFiles/include/blender_vscode/load_addons.py b/pythonFiles/include/blender_vscode/load_addons.py index 64f8c5d..d5ff0dc 100644 --- a/pythonFiles/include/blender_vscode/load_addons.py +++ b/pythonFiles/include/blender_vscode/load_addons.py @@ -4,9 +4,20 @@ import traceback from pathlib import Path from . communication import send_dict_as_json -from . environment import user_addon_directory, addon_directories +from . environment import get_user_addon_directory, addon_directories + def setup_addon_links(addons_to_load): + + user_addon_directory = get_user_addon_directory(Path(next(addons_to_load.keys()))) + print(f"USER ADDON: {user_addon_directory}") + print(f"USER ADDON: {user_addon_directory}") + print(f"USER ADDON: {user_addon_directory}") + print(f"USER ADDON: {user_addon_directory}") + print(f"USER ADDON: {user_addon_directory}") + print(f"USER ADDON: {user_addon_directory}") + print(f"USER ADDON: {user_addon_directory}") + print(f"USER ADDON: {user_addon_directory}") if not os.path.exists(user_addon_directory): os.makedirs(user_addon_directory) diff --git a/src/utils.ts b/src/utils.ts index aef5190..d104b3b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -46,9 +46,11 @@ export function handleErrors(func: () => Promise) { try { await func(); } - catch (err: any) { - if (err.message !== CANCEL) { - vscode.window.showErrorMessage(err.message); + catch (err) { + if (err instanceof Error) { + if (err.message !== CANCEL) { + vscode.window.showErrorMessage(err.message); + } } } };