Salome HOME
integration second patch de Pascal
[tools/sat.git] / src / fileEnviron.py
index 3fe41c87945290dc5524abfb57bf98f015cc91e8..947b8ba3822985635d22bc84839f058dad55f534 100644 (file)
@@ -761,7 +761,8 @@ launcher_header2="""\
 import os
 import sys
 import subprocess
-
+import os.path
+import imp
 
 # Add the pwdPath to able to run the launcher after unpacking a package
 # Used only in case of a salomeTools package
@@ -835,7 +836,8 @@ launcher_header3="""\
 import os
 import sys
 import subprocess
-
+import os.path
+import imp
 
 # Add the pwdPath to able to run the launcher after unpacking a package
 # Used only in case of a salomeTools package
@@ -904,6 +906,26 @@ def main(args):
 """
 
 launcher_tail_py2="""\
+    #[hook to integrate in launcher additionnal user modules]
+    
+    # Load all files extra.env.d/*.py and call the module's init routine]
+
+    extradir=out_dir_Path + r"/extra.env.d"
+
+    if os.path.exists(extradir):
+        sys.path.insert(0, os.path.join(os.getcwd(), extradir))
+        for filename in sorted(
+            filter(lambda x: os.path.isfile(os.path.join(extradir, x)),
+                   os.listdir(extradir))):
+
+            if filename.endswith(".py"):
+                f = os.path.join(extradir, filename)
+                module_name = os.path.splitext(os.path.basename(f))[0]
+                fp, path, desc = imp.find_module(module_name)
+                module = imp.load_module(module_name, fp, path, desc)
+                module.init(context, out_dir_Path)
+
+    #[manage salome doc command]
     if len(args) >1 and args[0]=='doc':
         _showDoc(args[1:])
         return
@@ -937,6 +959,26 @@ if __name__ == "__main__":
 """
 
 launcher_tail_py3="""\
+    #[hook to integrate in launcher additionnal user modules]
+    
+    # Load all files extra.env.d/*.py and call the module's init routine]
+
+    extradir=out_dir_Path + r"/extra.env.d"
+
+    if os.path.exists(extradir):
+        sys.path.insert(0, os.path.join(os.getcwd(), extradir))
+        for filename in sorted(
+            filter(lambda x: os.path.isfile(os.path.join(extradir, x)),
+                   os.listdir(extradir))):
+
+            if filename.endswith(".py"):
+                f = os.path.join(extradir, filename)
+                module_name = os.path.splitext(os.path.basename(f))[0]
+                fp, path, desc = imp.find_module(module_name)
+                module = imp.load_module(module_name, fp, path, desc)
+                module.init(context, out_dir_Path)
+
+    #[manage salome doc command]
     if len(args) >1 and args[0]=='doc':
         _showDoc(args[1:])
         return