From: Anthony Geay Date: Tue, 18 May 2021 09:40:26 +0000 (+0200) Subject: G. David : Shell Script written in env.d application directory executing module loads... X-Git-Tag: EMC2P_DEV_2021_05^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Femc2p%2Fadd_envModules_file_in_appli;p=modules%2Fkernel.git G. David : Shell Script written in env.d application directory executing module loads found in config_appli.xml --- 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'))