Browse Source

Finish fixing bash_profile loading

Hamilton Turner 11 years ago
parent
commit
200ce85b9e

+ 4 - 6
toolset/benchmark/framework_test.py

@@ -288,12 +288,10 @@ class FrameworkTest:
   ############################################################
   def start(self, out, err):
     # Load profile for this installation
-    test_profile="%s/bash_profile.sh" % self.directory
-    if os.path.exists(test_profile):
-      setup_util.replace_environ(config=test_profile)
-    else:
-      logging.warning("Framework %s does not have a bash_profile" % test_name)
-      setup_util.replace_environ(config="$FWROOT/config/benchmark_profile")
+    profile="%s/bash_profile.sh" % self.directory
+    if not os.path.exists(profile):
+      logging.warning("Framework %s does not have a bash_profile" % self.name)
+      profile="$FWROOT/config/benchmark_profile"
     
     set_iroot="export IROOT=%s" % self.install_root
     setup_util.replace_environ(config=profile, command=set_iroot)

+ 4 - 5
toolset/setup/linux/installer.py

@@ -72,12 +72,11 @@ class Installer:
               os.makedirs(test_install_dir)
 
             # Load profile for this installation
-            test_profile_file="%s/bash_profile.sh" % test_dir
-            if os.path.exists(test_profile_file):
-              setup_util.replace_environ(config=test_profile_file)
-            else:
+            profile="%s/bash_profile.sh" % test_dir
+            if not os.path.exists(profile):
               logging.warning("Framework %s does not have a bash_profile"%test_name)
-              setup_util.replace_environ(config="$FWROOT/config/benchmark_profile")
+              profile="$FWROOT/config/benchmark_profile"
+            setup_util.replace_environ(config=profile)
 
             # Find relative installation file
             test_rel_install_file = "$FWROOT%s" % setup_util.path_relative_to_root(test_install_file)

+ 4 - 4
toolset/setup/linux/setup_util.py

@@ -19,8 +19,7 @@ def replace_text(file, to_replace, replacement):
 # Note: This will not replace the sudo environment (e.g. subprocess.check_call("sudo <command>")). 
 # If you must use sudo, consider sudo sh -c ". <config> && your_command"
 def replace_environ(config=None, root=None, print_result=False, command='true'):
-    # Source file and print resulting environment
-    setup_env = "%s && . %s && env" % (command, config)
+    # Clean up our current environment, preserving some important items
     mini_environ = os.environ.copy()
     mini_environ.clear()
     if 'HOME' in os.environ.keys():
@@ -33,13 +32,14 @@ def replace_environ(config=None, root=None, print_result=False, command='true'):
         mini_environ['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
     if 'PYTHONPATH' in os.environ.keys():
         mini_environ['PYTHONPATH'] = os.environ['PYTHONPATH']
-
     if root is not None: 
       mini_environ['FWROOT']=root
     elif 'FWROOT' in os.environ.keys():
         mini_environ['FWROOT']=os.environ['FWROOT']
-    
     os.environ.clear()
+
+    # Run command, source config file, and store resulting environment
+    setup_env = "%s && . %s && env" % (command, config)
     env = subprocess.check_output(setup_env, shell=True, env=mini_environ,
       executable='/bin/bash')
     for line in env.split('\n'):