Salome HOME
Fix command to set the module environment gdd/fix_env_modules
authorGilles DAVID <gilles-g.david@edf.fr>
Wed, 16 Jan 2019 12:55:42 +0000 (13:55 +0100)
committerGilles DAVID <gilles-g.david@edf.fr>
Wed, 16 Jan 2019 13:14:38 +0000 (14:14 +0100)
Previous command modulecmd is not used anymore on Debian 9.
A fix is to search for the LMOD_CMD environement variable.
This suppose that lmod is installed.

bin/salomeContext.py

index 0d65b379716650abefb1879ed79baa32c02d5b46..3ab39b637b096a87a643f6755566b6f87c1ee1f8 100644 (file)
@@ -101,10 +101,14 @@ class SalomeContext:
   #
 
   def __loadEnvModules(self, env_modules):
-    print("Trying to load env modules: %s..." % ' '.join(env_modules))
+    print("Trying to load env modules: %s ..." % ' '.join(env_modules))
+    modulecmd = os.getenv('LMOD_CMD')
+    if not modulecmd:
+      print('Module environment not present')
+      return
     try:
-      out, err = subprocess.Popen(["modulecmd", "python", "load"] + env_modules, stdout=subprocess.PIPE).communicate()
-      exec(out) # define specific environment variables
+      out, err = subprocess.Popen([modulecmd, "python", "load"] + env_modules, stdout=subprocess.PIPE).communicate()
+      exec(out)  # define specific environment variables
       print("OK")
     except:
       print("** Failed **")