def get_installed_and_missing_repository_dependencies_for_new_install( trans, repo_info_tuple ): """ Parse the received repository_dependencies dictionary that is associated with a repository being installed into Galaxy for the first time and attempt to determine repository dependencies that are already installed and those that are not. """ missing_repository_dependencies = {} installed_repository_dependencies = {} missing_rd_tups = [] installed_rd_tups = [] description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, installed_td = \ suc.get_repo_info_tuple_contents( repo_info_tuple ) if repository_dependencies: description = repository_dependencies[ 'description' ] root_key = repository_dependencies[ 'root_key' ] # The repository dependencies container will include only the immediate repository dependencies of this repository, so the container will be # only a single level in depth. for key, rd_tups in repository_dependencies.items(): if key in [ 'description', 'root_key' ]: continue for rd_tup in rd_tups: tool_shed, name, owner, changeset_revision, prior_installation_required = suc.parse_repository_dependency_tuple( rd_tup ) # Updates to installed repository revisions may have occurred, so make sure to locate the appropriate repository revision if one exists. # We need to create a temporary repo_info_tuple that includes the correct repository owner which we get from the current rd_tup. The current # tuple looks like: ( description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, installed_td ) tmp_clone_url = suc.generate_clone_url_from_repo_info_tup( rd_tup ) tmp_repo_info_tuple = ( None, tmp_clone_url, changeset_revision, None, owner, None, None ) repository, current_changeset_revision = suc.repository_was_previously_installed( trans, tool_shed, name, tmp_repo_info_tuple ) if repository: new_rd_tup = [ tool_shed, name, owner, changeset_revision, str( prior_installation_required ), repository.id, repository.status ] if repository.status == trans.model.ToolShedRepository.installation_status.INSTALLED: if new_rd_tup not in installed_rd_tups: installed_rd_tups.append( new_rd_tup ) else: if new_rd_tup not in missing_rd_tups: missing_rd_tups.append( new_rd_tup ) else: new_rd_tup = [ tool_shed, name, owner, changeset_revision, str( prior_installation_required ), None, 'Never installed' ] if new_rd_tup not in missing_rd_tups: missing_rd_tups.append( new_rd_tup ) if installed_rd_tups: installed_repository_dependencies[ 'root_key' ] = root_key installed_repository_dependencies[ root_key ] = installed_rd_tups installed_repository_dependencies[ 'description' ] = description if missing_rd_tups: missing_repository_dependencies[ 'root_key' ] = root_key missing_repository_dependencies[ root_key ] = missing_rd_tups missing_repository_dependencies[ 'description' ] = description return installed_repository_dependencies, missing_repository_dependencies
def get_installed_and_missing_repository_dependencies_for_new_install( trans, repo_info_tuple ): """ Parse the received repository_dependencies dictionary that is associated with a repository being installed into Galaxy for the first time and attempt to determine repository dependencies that are already installed and those that are not. """ missing_repository_dependencies = {} installed_repository_dependencies = {} missing_rd_tups = [] installed_rd_tups = [] description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies = \ suc.get_repo_info_tuple_contents( repo_info_tuple ) if repository_dependencies: description = repository_dependencies[ 'description' ] root_key = repository_dependencies[ 'root_key' ] # The repository dependencies container will include only the immediate repository dependencies of this repository, so the container will be # only a single level in depth. for key, rd_tups in repository_dependencies.items(): if key in [ 'description', 'root_key' ]: continue for rd_tup in rd_tups: tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td = \ common_util.parse_repository_dependency_tuple( rd_tup ) # Updates to installed repository revisions may have occurred, so make sure to locate the appropriate repository revision if one exists. # We need to create a temporary repo_info_tuple that includes the correct repository owner which we get from the current rd_tup. The current # tuple looks like: ( description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, installed_td ) tmp_clone_url = suc.generate_clone_url_from_repo_info_tup( rd_tup ) tmp_repo_info_tuple = ( None, tmp_clone_url, changeset_revision, None, owner, None, None ) repository, installed_changeset_revision = suc.repository_was_previously_installed( trans, tool_shed, name, tmp_repo_info_tuple ) if repository: new_rd_tup = [ tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td, repository.id, repository.status ] if repository.status == trans.install_model.ToolShedRepository.installation_status.INSTALLED: if new_rd_tup not in installed_rd_tups: installed_rd_tups.append( new_rd_tup ) else: # A repository dependency that is not installed will not be considered missing if it's value for only_if_compiling_contained_td is # True This is because this type of repository dependency will only be considered at the time that the specified tool dependency # is being installed, and even then only if the compiled binary of the tool dependency could not be installed due to the unsupported # installation environment. if not util.asbool( only_if_compiling_contained_td ): if new_rd_tup not in missing_rd_tups: missing_rd_tups.append( new_rd_tup ) else: new_rd_tup = [ tool_shed, name, owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td, None, 'Never installed' ] if not util.asbool( only_if_compiling_contained_td ): # A repository dependency that is not installed will not be considered missing if it's value for only_if_compiling_contained_td is # True - see above... if new_rd_tup not in missing_rd_tups: missing_rd_tups.append( new_rd_tup ) if installed_rd_tups: installed_repository_dependencies[ 'root_key' ] = root_key installed_repository_dependencies[ root_key ] = installed_rd_tups installed_repository_dependencies[ 'description' ] = description if missing_rd_tups: missing_repository_dependencies[ 'root_key' ] = root_key missing_repository_dependencies[ root_key ] = missing_rd_tups missing_repository_dependencies[ 'description' ] = description return installed_repository_dependencies, missing_repository_dependencies