mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-15 01:58:35 +05:00
minor correction:
to avoid the critical message of PluginsManager when SMESH_PYPLUGIN_DIR are not declared
This commit is contained in:
parent
49eb5ff195
commit
e60bcaf4a9
@ -122,23 +122,25 @@ import sys
|
|||||||
import importlib
|
import importlib
|
||||||
import importlib.util
|
import importlib.util
|
||||||
|
|
||||||
plugin_dirs = os.getenv("SMESH_PYPLUGIN_DIR").split(":")
|
smesh_pyplugin_dir = os.getenv("SMESH_PYPLUGIN_DIR")
|
||||||
# reverse plugin_dirs list to call smesh python plugin in good order
|
if smesh_pyplugin_dir:
|
||||||
plugin_dirs.reverse()
|
plugin_dirs = smesh_pyplugin_dir.split(":")
|
||||||
for plg_dir in plugin_dirs:
|
# reverse plugin_dirs list to call smesh python plugin in good order
|
||||||
if os.path.exists(plg_dir):
|
plugin_dirs.reverse()
|
||||||
sys.path.insert(0, plg_dir)
|
for plg_dir in plugin_dirs:
|
||||||
#for filename in sorted(
|
if os.path.exists(plg_dir):
|
||||||
# filter(lambda x: os.path.isfile(os.path.join(plg_dir, x)),
|
sys.path.insert(0, plg_dir)
|
||||||
# os.listdir(plg_dir))):
|
#for filename in sorted(
|
||||||
for filename in os.listdir(plg_dir):
|
# filter(lambda x: os.path.isfile(os.path.join(plg_dir, x)),
|
||||||
if filename.endswith(".py"):
|
# os.listdir(plg_dir))):
|
||||||
f = os.path.join(plg_dir, filename)
|
for filename in os.listdir(plg_dir):
|
||||||
try:
|
if filename.endswith(".py"):
|
||||||
module_name = os.path.splitext(os.path.basename(f))[0]
|
f = os.path.join(plg_dir, filename)
|
||||||
_specs = importlib.util.find_spec(module_name)
|
try:
|
||||||
_module = importlib.util.module_from_spec(_specs)
|
module_name = os.path.splitext(os.path.basename(f))[0]
|
||||||
_specs.loader.exec_module(_module)
|
_specs = importlib.util.find_spec(module_name)
|
||||||
_module.init()
|
_module = importlib.util.module_from_spec(_specs)
|
||||||
except:
|
_specs.loader.exec_module(_module)
|
||||||
print("Can not load python plugin from {}".format(plg_dir))
|
_module.init()
|
||||||
|
except:
|
||||||
|
print("Can not load python plugin from {}".format(plg_dir))
|
||||||
|
Loading…
Reference in New Issue
Block a user