2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/08b05ff1c7cf/ Changeset: 08b05ff1c7cf Branch: next-stable User: Dave Bouvier Date: 2013-05-23 21:49:46 Summary: Fix of environment variables being set in set_environment_for_install, but not being propagated to set_environment actions. Affected #: 1 file diff -r 5ee2362aff09f103891075c218f7474a662e569b -r 08b05ff1c7cfaad179d25970df0b740da282550e lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py @@ -22,6 +22,7 @@ log = logging.getLogger( __name__ ) +CMD_SEPARATOR = '__CMD_SEP__' INSTALLATION_LOG = 'INSTALLATION.log' VIRTUALENV_URL = 'https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.9.1.tar.gz' @@ -49,6 +50,29 @@ return output return output.return_code +def handle_environment_variables( app, tool_dependency, install_dir, env_var_dict, set_prior_environment_commands ): + env_var_value = env_var_dict[ 'value' ] + if '$ENV[' in env_var_value and ']' in env_var_value: + # Pull out the name of the environment variable to populate. + inherited_env_var_name = env_var_value.split( '[' )[1].split( ']' )[0] + to_replace = '$ENV[%s]' % inherited_env_var_name + # Build a command line that outputs CMD_SEPARATOR + environment variable value + CMD_SEPARATOR. + set_prior_environment_commands.extend( [ "echo '%s'" % CMD_SEPARATOR, 'echo $%s' % inherited_env_var_name, "echo '%s'" % CMD_SEPARATOR ] ) + command = ' ; '.join( set_prior_environment_commands ) + # Run the command and capture the output. + command_return = handle_command( app, tool_dependency, install_dir, command, return_output=True ) + # And extract anything between the two instances of CMD_SEPARATOR. + environment_variable_value = command_return.split( CMD_SEPARATOR )[1].split( CMD_SEPARATOR )[0].strip( '\n' ) + if environment_variable_value: + log.info( 'Replacing %s with %s in env.sh for this repository.', to_replace, environment_variable_value ) + env_var_value = env_var_value.replace( to_replace, environment_variable_value ) + else: + # If the return is empty, replace the original $ENV[] with nothing, to avoid any shell misparsings later on. + log.error( 'Environment variable %s not found, removing from set_environment.', inherited_env_var_name ) + env_var_value = env_var_value.replace( to_replace, '$%s' % inherited_env_var_name ) + env_var_dict[ 'value' ] = env_var_value + return env_var_dict + def install_virtualenv( app, venv_dir ): if not os.path.exists( venv_dir ): with make_tmp_dir() as work_dir: @@ -149,10 +173,18 @@ destination_dir=os.path.join( action_dict[ 'destination' ] ) ) elif action_type == 'set_environment': # Currently the only action supported in this category is "environment_variable". + # Build a command line from the prior_installation_required, in case an environment variable is referenced + # in the set_environment action. + cmds = [] + for env_shell_file_path in env_shell_file_paths: + for i, env_setting in enumerate( open( env_shell_file_path ) ): + cmds.append( env_setting.strip( '\n' ) ) env_var_dicts = action_dict[ 'environment_variable' ] for env_var_dict in env_var_dicts: - cmd = common_util.create_or_update_env_shell_file( install_dir, env_var_dict ) - return_code = handle_command( app, tool_dependency, install_dir, cmd ) + # Check for the presence of the $ENV[] key string and populate it if possible. + env_var_dict = handle_environment_variables( app, tool_dependency, install_dir, env_var_dict, cmds ) + env_command = common_util.create_or_update_env_shell_file( install_dir, env_var_dict ) + return_code = handle_command( app, tool_dependency, install_dir, env_command ) if return_code: return elif action_type == 'set_environment_for_install': https://bitbucket.org/galaxy/galaxy-central/commits/cf574a68a1f9/ Changeset: cf574a68a1f9 User: Dave Bouvier Date: 2013-05-23 21:50:34 Summary: Merged in next-stable. Affected #: 1 file diff -r 681e2c7658482d6148fad734c5080c164efae8b7 -r cf574a68a1f95524b9412e0944ee2cd705a63ce5 lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/fabric_util.py @@ -22,6 +22,7 @@ log = logging.getLogger( __name__ ) +CMD_SEPARATOR = '__CMD_SEP__' INSTALLATION_LOG = 'INSTALLATION.log' VIRTUALENV_URL = 'https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.9.1.tar.gz' @@ -49,6 +50,29 @@ return output return output.return_code +def handle_environment_variables( app, tool_dependency, install_dir, env_var_dict, set_prior_environment_commands ): + env_var_value = env_var_dict[ 'value' ] + if '$ENV[' in env_var_value and ']' in env_var_value: + # Pull out the name of the environment variable to populate. + inherited_env_var_name = env_var_value.split( '[' )[1].split( ']' )[0] + to_replace = '$ENV[%s]' % inherited_env_var_name + # Build a command line that outputs CMD_SEPARATOR + environment variable value + CMD_SEPARATOR. + set_prior_environment_commands.extend( [ "echo '%s'" % CMD_SEPARATOR, 'echo $%s' % inherited_env_var_name, "echo '%s'" % CMD_SEPARATOR ] ) + command = ' ; '.join( set_prior_environment_commands ) + # Run the command and capture the output. + command_return = handle_command( app, tool_dependency, install_dir, command, return_output=True ) + # And extract anything between the two instances of CMD_SEPARATOR. + environment_variable_value = command_return.split( CMD_SEPARATOR )[1].split( CMD_SEPARATOR )[0].strip( '\n' ) + if environment_variable_value: + log.info( 'Replacing %s with %s in env.sh for this repository.', to_replace, environment_variable_value ) + env_var_value = env_var_value.replace( to_replace, environment_variable_value ) + else: + # If the return is empty, replace the original $ENV[] with nothing, to avoid any shell misparsings later on. + log.error( 'Environment variable %s not found, removing from set_environment.', inherited_env_var_name ) + env_var_value = env_var_value.replace( to_replace, '$%s' % inherited_env_var_name ) + env_var_dict[ 'value' ] = env_var_value + return env_var_dict + def install_virtualenv( app, venv_dir ): if not os.path.exists( venv_dir ): with make_tmp_dir() as work_dir: @@ -149,10 +173,18 @@ destination_dir=os.path.join( action_dict[ 'destination' ] ) ) elif action_type == 'set_environment': # Currently the only action supported in this category is "environment_variable". + # Build a command line from the prior_installation_required, in case an environment variable is referenced + # in the set_environment action. + cmds = [] + for env_shell_file_path in env_shell_file_paths: + for i, env_setting in enumerate( open( env_shell_file_path ) ): + cmds.append( env_setting.strip( '\n' ) ) env_var_dicts = action_dict[ 'environment_variable' ] for env_var_dict in env_var_dicts: - cmd = common_util.create_or_update_env_shell_file( install_dir, env_var_dict ) - return_code = handle_command( app, tool_dependency, install_dir, cmd ) + # Check for the presence of the $ENV[] key string and populate it if possible. + env_var_dict = handle_environment_variables( app, tool_dependency, install_dir, env_var_dict, cmds ) + env_command = common_util.create_or_update_env_shell_file( install_dir, env_var_dict ) + return_code = handle_command( app, tool_dependency, install_dir, env_command ) if return_code: return elif action_type == 'set_environment_for_install': Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.