'Install specified dependencies for repository tools.  The received list of tool_dependencies
are the database records for those dependencies defined in the tool_dependencies.xml file
(contained in the repository) that should be installed.  This allows for filtering out dependencies
that have not been checked for installation on the \'Manage tool dependencies\' page for an installed
tool shed repository.'

@web.expose
@web.require_admin
def initiate_tool_dependency_installation(self, trans, tool_dependencies, **kwd):

    message = str(escape(kwd.get('message', '')))
    status = kwd.get('status', 'done')
    err_msg = ''
    tool_shed_repository = tool_dependencies[0].tool_shed_repository
    tool_dependencies_config = hg_util.get_config_from_disk(rt_util.TOOL_DEPENDENCY_DEFINITION_FILENAME, tool_shed_repository.repo_path(trans.app))
    itdm = install_manager.InstallToolDependencyManager(trans.app)
    installed_tool_dependencies = itdm.install_specified_tool_dependencies(tool_shed_repository=tool_shed_repository, tool_dependencies_config=tool_dependencies_config, tool_dependencies=tool_dependencies, from_tool_migration_manager=False)
    for installed_tool_dependency in installed_tool_dependencies:
        if (installed_tool_dependency.status == trans.app.install_model.ToolDependency.installation_status.ERROR):
            text = util.unicodify(installed_tool_dependency.error_message)
            if (text is not None):
                err_msg += ('        %s' % text)
    if err_msg:
        message += err_msg
        status = 'error'
    message += ('Installed    tool    dependencies:    %s' % ',    '.join((td.name for td in installed_tool_dependencies)))
    td_ids = [trans.security.encode_id(td.id) for td in tool_shed_repository.tool_dependencies]
    return trans.response.send_redirect(web.url_for(controller='admin_toolshed', action='manage_tool_dependencies', tool_dependency_ids=td_ids, message=message, status=status))
