From a1f3f84d3fcce07d8afbfeeda9cf84adf6053426 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 18 May 2021 11:40:26 +0200 Subject: [PATCH] G. David : Shell Script written in env.d application directory executing module loads found in config_appli.xml --- bin/appli_gen.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/bin/appli_gen.py b/bin/appli_gen.py index a58eb7a41..89650dffa 100755 --- a/bin/appli_gen.py +++ b/bin/appli_gen.py @@ -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')) -- 2.39.2