From 4640f115de3b2f605479a42ffbafbc470ebb5079 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 17 Jun 2024 21:02:19 +0800 Subject: [PATCH] implement try except statement - ondrej's comment --- .../maya/client/ayon_maya/api/menu.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/server_addon/maya/client/ayon_maya/api/menu.py b/server_addon/maya/client/ayon_maya/api/menu.py index 131c406cb4..4693d0e131 100644 --- a/server_addon/maya/client/ayon_maya/api/menu.py +++ b/server_addon/maya/client/ayon_maya/api/menu.py @@ -75,14 +75,17 @@ def install(project_settings): cmds.setParent("..", menu=True) - ayon_menu = project_settings["core"]["tools"].get("ayon_menu") - if ayon_menu: - if ayon_menu.get("version_up_current_workfile"): - cmds.menuItem(divider=True) - cmds.menuItem( - "Version Up Workfile", - command=lambda *args: version_up_current_workfile() - ) + try: + if project_settings["core"]["tools"]["ayon_menu"].get( + "version_up_current_workfile"): + cmds.menuItem(divider=True) + cmds.menuItem( + "Version Up Workfile", + command=lambda *args: version_up_current_workfile() + ) + except KeyError: + print("Version Up Workfile setting not found in " + "Core Settings. Please update Core Addon") cmds.menuItem(divider=True)