Salome HOME
updated copyright message
[modules/gui.git] / src / SalomeApp / salome_pluginsmanager.py
old mode 100755 (executable)
new mode 100644 (file)
index f17bab2..fb27bef
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -244,8 +244,13 @@ class PluginsManager:
 
     def importPlugins(self):
         """Execute the salome_plugins file that contains plugins definition """
+        ior_fake_ns = None
+        prefix_ior = "--iorfakens="
+        presence_ior = [elt for elt in QApplication.arguments() if elt[:len(prefix_ior)]==prefix_ior]
+        if any(presence_ior):
+          ior_fake_ns = presence_ior[-1][len(prefix_ior):]
         if self.lasttime ==0 or salome.myStudy == None:
-          salome.salome_init(embedded=True)
+          salome.salome_init(embedded=True,iorfakensfile=ior_fake_ns)
 
         lasttime=0
 
@@ -281,7 +286,8 @@ class PluginsManager:
               sys.path.insert(0,directory)
               logger.debug("The directory %s has been added to PYTHONPATH"%directory)
             try:
-              exec(compile(open(plugins_file,'rb').read(), plugins_file, 'exec'),globals(),{})
+              with open(plugins_file, 'rb') as fp:
+                exec(compile(fp.read(), plugins_file, 'exec'), globals(), {})
             except:
               logger.critical("Error while loading plugins from file %s"%plugins_file)
               traceback.print_exc()