From e60bcaf4a9acf07862ada57df5d0712a71ed67c1 Mon Sep 17 00:00:00 2001 From: DUC ANH HOANG Date: Tue, 12 Nov 2024 11:24:56 +0100 Subject: [PATCH] minor correction: to avoid the critical message of PluginsManager when SMESH_PYPLUGIN_DIR are not declared --- src/Tools/smesh_plugins.py | 42 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Tools/smesh_plugins.py b/src/Tools/smesh_plugins.py index 5b9194d59..50cd7da4f 100644 --- a/src/Tools/smesh_plugins.py +++ b/src/Tools/smesh_plugins.py @@ -122,23 +122,25 @@ import sys import importlib import importlib.util -plugin_dirs = os.getenv("SMESH_PYPLUGIN_DIR").split(":") -# reverse plugin_dirs list to call smesh python plugin in good order -plugin_dirs.reverse() -for plg_dir in plugin_dirs: - if os.path.exists(plg_dir): - sys.path.insert(0, plg_dir) - #for filename in sorted( - # filter(lambda x: os.path.isfile(os.path.join(plg_dir, x)), - # os.listdir(plg_dir))): - for filename in os.listdir(plg_dir): - if filename.endswith(".py"): - f = os.path.join(plg_dir, filename) - try: - module_name = os.path.splitext(os.path.basename(f))[0] - _specs = importlib.util.find_spec(module_name) - _module = importlib.util.module_from_spec(_specs) - _specs.loader.exec_module(_module) - _module.init() - except: - print("Can not load python plugin from {}".format(plg_dir)) +smesh_pyplugin_dir = os.getenv("SMESH_PYPLUGIN_DIR") +if smesh_pyplugin_dir: + plugin_dirs = smesh_pyplugin_dir.split(":") + # reverse plugin_dirs list to call smesh python plugin in good order + plugin_dirs.reverse() + for plg_dir in plugin_dirs: + if os.path.exists(plg_dir): + sys.path.insert(0, plg_dir) + #for filename in sorted( + # filter(lambda x: os.path.isfile(os.path.join(plg_dir, x)), + # os.listdir(plg_dir))): + for filename in os.listdir(plg_dir): + if filename.endswith(".py"): + f = os.path.join(plg_dir, filename) + try: + module_name = os.path.splitext(os.path.basename(f))[0] + _specs = importlib.util.find_spec(module_name) + _module = importlib.util.module_from_spec(_specs) + _specs.loader.exec_module(_module) + _module.init() + except: + print("Can not load python plugin from {}".format(plg_dir)) -- 2.39.2