]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
G. David : Shell Script written in env.d application directory executing module loads... emc2p/add_envModules_file_in_appli EMC2P_DEV_2021_05
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 18 May 2021 09:40:26 +0000 (11:40 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 18 May 2021 09:40:26 +0000 (11:40 +0200)
bin/appli_gen.py

index a58eb7a41d3a52bce192ecea367a18546b6350de..89650dffa1a405395a2358d498a7832d1c49b94a 100755 (executable)
@@ -285,6 +285,16 @@ def install(prefix, config_file, verbose=0):
         shutil.copyfile(filename, os.path.join(home_dir,"config_appli.xml"))
         pass
 
+    # Creation of env.d directory
+    virtual_salome.mkdir(os.path.join(home_dir,'env.d'))
+
+    # Get the env modules which will be loaded
+    # In the same way as: module load [MODULE_LIST]
+    env_modules = _config.get('env_modules', [])
+    if env_modules:
+        with open(os.path.join(home_dir, 'env.d', 'envModules.sh'), 'w') as fd:
+            fd.write('#!/bin/bash\n')
+            fd.write('module load %s\n' % (' '.join(env_modules)))
 
     # Copy salome / salome_mesa scripts:
 
@@ -293,9 +303,8 @@ def install(prefix, config_file, verbose=0):
         salome_file = os.path.join(home_dir, scripts)
         try:
             os.remove(salome_file)
-        except:
+        except Exception:
             pass
-        env_modules = _config.get('env_modules', [])
         with open(salome_file, 'w') as fd:
             fd.write(salome_script.replace('MODULES = []', 'MODULES = {}'.format(env_modules)))
             os.chmod(salome_file, 0o755)
@@ -304,10 +313,6 @@ def install(prefix, config_file, verbose=0):
     shutil.copyfile(os.path.join(appliskel_dir, ".salome-completion.sh"),
                     os.path.join(home_dir, ".salome-completion.sh"))
 
-
-    # Creation of env.d directory
-    virtual_salome.mkdir(os.path.join(home_dir,'env.d'))
-
     if "prereq_path" in _config and os.path.isfile(_config["prereq_path"]):
         shutil.copyfile(_config["prereq_path"],
                         os.path.join(home_dir, 'env.d', 'envProducts.sh'))