diff --git a/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py b/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py index c129e58a9a8..fad6353e64e 100755 --- a/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py @@ -146,16 +146,21 @@ def create_env_var_dict( elem, tool_dependency_install_dir=None, tool_shed_repos return None def create_or_update_env_shell_file( install_dir, env_var_dict ): - env_var_name = env_var_dict[ 'name' ] env_var_action = env_var_dict[ 'action' ] env_var_value = env_var_dict[ 'value' ] - if env_var_action == 'prepend_to': - changed_value = '%s:$%s' % ( env_var_value, env_var_name ) - elif env_var_action == 'set_to': - changed_value = '%s' % env_var_value - elif env_var_action == 'append_to': - changed_value = '$%s:%s' % ( env_var_name, env_var_value ) - line = "%s=%s; export %s" % ( env_var_name, changed_value, env_var_name ) + if env_var_action in ['prepend_to', 'set_to', 'append_to']: + env_var_name = env_var_dict[ 'name' ] + if env_var_action == 'prepend_to': + changed_value = '%s:$%s' % ( env_var_value, env_var_name ) + elif env_var_action == 'set_to': + changed_value = '%s' % env_var_value + elif env_var_action == 'append_to': + changed_value = '$%s:%s' % ( env_var_name, env_var_value ) + line = "%s=%s; export %s" % ( env_var_name, changed_value, env_var_name ) + elif env_var_action == "source": + line = ". %s" % env_var_value + else: + raise Exception( "Unknown shell file action %s" % env_var_action ) env_shell_file_path = os.path.join( install_dir, 'env.sh' ) return line, env_shell_file_path diff --git a/test/unit/tool_shed/test_td_common_util.py b/test/unit/tool_shed/test_td_common_util.py index 60f2daebf03..c260cec667c 100644 --- a/test/unit/tool_shed/test_td_common_util.py +++ b/test/unit/tool_shed/test_td_common_util.py @@ -29,6 +29,10 @@ def test_create_or_update_env_shell_file( ): assert path == join( TEST_INSTALL_DIR, "env.sh" ) assert line == "R_LIBS=/usr/share/R/libs; export R_LIBS" + line, path = td_common_util.create_or_update_env_shell_file( TEST_INSTALL_DIR, dict(action="source", value=test_path)) + assert path == join( TEST_INSTALL_DIR, "env.sh" ) + assert line == ". /usr/share/R/libs" + def test_parse_setup_environment_repositories( ): xml = """