Salome HOME
Try to kill Salome application when a YACS Launcher job is killed
[modules/kernel.git] / src / KERNEL_PY / salome_shared_modules.py
index f746809856f1b4b2f01183a92f16750e209ddc20..d510c2289f9c0bd017e71e5fa8f34750b4cda561 100755 (executable)
@@ -1,29 +1,29 @@
-#  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-# 
-#  This library is free software; you can redistribute it and/or 
-#  modify it under the terms of the GNU Lesser General Public 
-#  License as published by the Free Software Foundation; either 
-#  version 2.1 of the License. 
-# 
-#  This library is distributed in the hope that it will be useful, 
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-#  Lesser General Public License for more details. 
-# 
-#  You should have received a copy of the GNU Lesser General Public 
-#  License along with this library; if not, write to the Free Software 
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-# 
-#  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+#  -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
 #
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
 #
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 #
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
 #  File   : salome_shared_modules.py
 #  Module : SALOME
-
-from SALOME_utilities import *
-
+#
 """
 This module with help of import_hook and *_shared_modules
 filters imports when using the embedded Python interpretor.
@@ -56,12 +56,19 @@ import glob,os,sys
 import import_hook
 # shared_imported, patterns, register_name, register_pattern
 # will be shared by all Python sub interpretors
-from import_hook import shared_imported
 from import_hook import patterns
 from import_hook import register_name
 from import_hook import register_pattern
 
 register_name("salome_shared_modules")
+register_name("omniORB")
+register_name("omnipatch")
+register_pattern(lambda(x):x.endswith("_idl"))
+register_pattern(lambda(x):x.startswith("omniORB."))
+
+from omnipatch import shared_imported
+shared_imported.update(import_hook.shared_imported)
+import_hook.shared_imported=shared_imported
 
 # Get the SALOMEPATH if set or else use KERNEL_ROOT_DIR that should be set.
 salome_path=os.environ.get("SALOMEPATH",os.getenv("KERNEL_ROOT_DIR"))
@@ -69,16 +76,24 @@ salome_path=os.environ.get("SALOMEPATH",os.getenv("KERNEL_ROOT_DIR"))
 list_modules=[]
 
 # Import all *_shared_modules in the path and store them in list_modules
-path=salome_path.split(":")
+splitter = ":"
+if sys.platform == "win32":
+  splitter = ";"
+path=salome_path.split(splitter)
+import platform
+libdir = "lib"
 for rep in path:
     # Import all *_shared_modules in rep
-    for f in glob.glob(os.path.join(rep,"lib","python"+sys.version[:3],"site-packages","salome","shared_modules","*_shared_modules.py")):
+    for f in glob.glob(os.path.join(rep,libdir,"python"+sys.version[:3],"site-packages","salome","shared_modules","*_shared_modules.py")):
         try:
            name=os.path.splitext(os.path.basename(f))[0]
            register_name(name)
+           #print name + " REGISTERED"
            m=__import__(name)
+           #print name + " IMPORTED"
            list_modules.append(m)
         except:
+           print "Exception during register and import shared module"
            pass
 
 # 
@@ -86,7 +101,7 @@ for rep in path:
 # we add them to shared_imported
 #
 for name,module in sys.modules.items():
-    if import_hook.is_shared(name) and shared_imported.get(name) is None:
+    if module and import_hook.is_shared(name) and not shared_imported.has_key(name):
        #print "Module shared added to shared_imported: ",name
        shared_imported[name]=module