def populate_tool_dependencies_dicts( trans, tool_shed_url, tool_path, repository_installed_tool_dependencies, repository_missing_tool_dependencies,
                                      required_repo_info_dicts ):
    """
    Return the populated installed_tool_dependencies and missing_tool_dependencies dictionaries for all repositories defined by entries in the received
    required_repo_info_dicts.
    """
    installed_tool_dependencies = None
    missing_tool_dependencies = None
    if repository_installed_tool_dependencies is None:
        repository_installed_tool_dependencies = {}
    else:
        # Add the install_dir attribute to the tool_dependencies.
        repository_installed_tool_dependencies = add_installation_directories_to_tool_dependencies( trans=trans,
                                                                                                    tool_dependencies=repository_installed_tool_dependencies )
    if repository_missing_tool_dependencies is None:
        repository_missing_tool_dependencies = {}
    else:
        # Add the install_dir attribute to the tool_dependencies.
        repository_missing_tool_dependencies = add_installation_directories_to_tool_dependencies( trans=trans,
                                                                                                  tool_dependencies=repository_missing_tool_dependencies )
    if required_repo_info_dicts:
        # Handle the tool dependencies defined for each of the repository's repository dependencies.
        for rid in required_repo_info_dicts:
            for name, repo_info_tuple in rid.items():
                description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies = \
                    suc.get_repo_info_tuple_contents( repo_info_tuple )
                if tool_dependencies:
                    # Add the install_dir attribute to the tool_dependencies.
                    tool_dependencies = add_installation_directories_to_tool_dependencies( trans=trans,
                                                                                           tool_dependencies=tool_dependencies )
                    # The required_repository may have been installed with a different changeset revision.
                    required_repository, installed_changeset_revision = suc.repository_was_previously_installed( trans, tool_shed_url, name, repo_info_tuple )
                    if required_repository:
                        required_repository_installed_tool_dependencies, required_repository_missing_tool_dependencies = \
                            get_installed_and_missing_tool_dependencies_for_installed_repository( trans, required_repository, tool_dependencies )
                        if required_repository_installed_tool_dependencies:
                            # Add the install_dir attribute to the tool_dependencies.
                            required_repository_installed_tool_dependencies = \
                                add_installation_directories_to_tool_dependencies( trans=trans,
                                                                                   tool_dependencies=required_repository_installed_tool_dependencies )
                            for td_key, td_dict in required_repository_installed_tool_dependencies.items():
                                if td_key not in repository_installed_tool_dependencies:
                                    repository_installed_tool_dependencies[ td_key ] = td_dict
                        if required_repository_missing_tool_dependencies:
                            # Add the install_dir attribute to the tool_dependencies.
                            required_repository_missing_tool_dependencies = \
                                add_installation_directories_to_tool_dependencies( trans=trans,
                                                                                   tool_dependencies=required_repository_missing_tool_dependencies )
                            for td_key, td_dict in required_repository_missing_tool_dependencies.items():
                                if td_key not in repository_missing_tool_dependencies:
                                    repository_missing_tool_dependencies[ td_key ] = td_dict
    if repository_installed_tool_dependencies:
        installed_tool_dependencies = repository_installed_tool_dependencies
    if repository_missing_tool_dependencies:
        missing_tool_dependencies = repository_missing_tool_dependencies
    return installed_tool_dependencies, missing_tool_dependencies
Example #2
0
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 create_repository_dependency_objects( self, tool_path, tool_shed_url, repo_info_dicts, install_repository_dependencies=False,
                                           no_changes_checked=False, tool_panel_section_id=None, new_tool_panel_section_label=None ):
     """
     Discover all repository dependencies and make sure all tool_shed_repository and
     associated repository_dependency records exist as well as the dependency relationships
     between installed repositories.  This method is called when uninstalled repositories
     are being reinstalled.  If the user elected to install repository dependencies, all
     items in the all_repo_info_dicts list will be processed.  However, if repository
     dependencies are not to be installed, only those items contained in the received
     repo_info_dicts list will be processed.
     """
     install_model = self.app.install_model
     log.debug( "Creating repository dependency objects..." )
     # The following list will be maintained within this method to contain all created
     # or updated tool shed repositories, including repository dependencies that may not
     # be installed.
     all_created_or_updated_tool_shed_repositories = []
     # There will be a one-to-one mapping between items in 3 lists:
     # created_or_updated_tool_shed_repositories, tool_panel_section_keys
     # and filtered_repo_info_dicts.  The 3 lists will filter out repository
     # dependencies that are not to be installed.
     created_or_updated_tool_shed_repositories = []
     tool_panel_section_keys = []
     # Repositories will be filtered (e.g., if already installed, if elected
     # to not be installed, etc), so filter the associated repo_info_dicts accordingly.
     filtered_repo_info_dicts = []
     # Discover all repository dependencies and retrieve information for installing
     # them.  Even if the user elected to not install repository dependencies we have
     # to make sure all repository dependency objects exist so that the appropriate
     # repository dependency relationships can be built.
     all_required_repo_info_dict = self.get_required_repo_info_dicts( tool_shed_url, repo_info_dicts )
     all_repo_info_dicts = all_required_repo_info_dict.get( 'all_repo_info_dicts', [] )
     if not all_repo_info_dicts:
         # No repository dependencies were discovered so process the received repositories.
         all_repo_info_dicts = [ rid for rid in repo_info_dicts ]
     for repo_info_dict in all_repo_info_dicts:
         # If the user elected to install repository dependencies, all items in the
         # all_repo_info_dicts list will be processed.  However, if repository dependencies
         # are not to be installed, only those items contained in the received repo_info_dicts
         # list will be processed but the all_repo_info_dicts list will be used to create all
         # defined repository dependency relationships.
         if self.is_in_repo_info_dicts( repo_info_dict, repo_info_dicts ) or install_repository_dependencies:
             for name, repo_info_tuple in repo_info_dict.items():
                 can_update_db_record = False
                 description, \
                 repository_clone_url, \
                 changeset_revision, \
                 ctx_rev, \
                 repository_owner, \
                 repository_dependencies, \
                 tool_dependencies = \
                 suc.get_repo_info_tuple_contents( repo_info_tuple )
                 # See if the repository has an existing record in the database.
                 repository_db_record, installed_changeset_revision = \
                     suc.repository_was_previously_installed( self.app, tool_shed_url, name, repo_info_tuple, from_tip=False )
                 if repository_db_record:
                     if repository_db_record.status in [ install_model.ToolShedRepository.installation_status.INSTALLED,
                                                         install_model.ToolShedRepository.installation_status.CLONING,
                                                         install_model.ToolShedRepository.installation_status.SETTING_TOOL_VERSIONS,
                                                         install_model.ToolShedRepository.installation_status.INSTALLING_REPOSITORY_DEPENDENCIES,
                                                         install_model.ToolShedRepository.installation_status.INSTALLING_TOOL_DEPENDENCIES,
                                                         install_model.ToolShedRepository.installation_status.LOADING_PROPRIETARY_DATATYPES ]:
                         debug_msg = "Skipping installation of revision %s of repository '%s' because it was installed " % \
                             ( str( changeset_revision ), str( repository_db_record.name ) )
                         debug_msg += "with the (possibly updated) revision %s and its current installation status is '%s'." % \
                             ( str( installed_changeset_revision ), str( repository_db_record.status ) )
                         log.debug( debug_msg )
                         can_update_db_record = False
                     else:
                         if repository_db_record.status in [ install_model.ToolShedRepository.installation_status.ERROR,
                                                             install_model.ToolShedRepository.installation_status.NEW,
                                                             install_model.ToolShedRepository.installation_status.UNINSTALLED ]:
                             # The current tool shed repository is not currently installed, so we can update its
                             # record in the database.
                             name = repository_db_record.name
                             installed_changeset_revision = repository_db_record.installed_changeset_revision
                             metadata_dict = repository_db_record.metadata
                             dist_to_shed = repository_db_record.dist_to_shed
                             can_update_db_record = True
                         elif repository_db_record.status in [ install_model.ToolShedRepository.installation_status.DEACTIVATED ]:
                             # The current tool shed repository is deactivated, so updating its database record
                             # is not necessary - just activate it.
                             log.debug( "Reactivating deactivated tool_shed_repository '%s'." % str( repository_db_record.name ) )
                             self.app.installed_repository_manager.activate_repository( repository_db_record )
                             # No additional updates to the database record are necessary.
                             can_update_db_record = False
                         elif repository_db_record.status not in [ install_model.ToolShedRepository.installation_status.NEW ]:
                             # Set changeset_revision here so suc.create_or_update_tool_shed_repository will find
                             # the previously installed and uninstalled repository instead of creating a new record.
                             changeset_revision = repository_db_record.installed_changeset_revision
                             self.reset_previously_installed_repository( repository_db_record )
                             can_update_db_record = True
                 else:
                     # No record exists in the database for the repository currently being processed.
                     installed_changeset_revision = changeset_revision
                     metadata_dict = {}
                     dist_to_shed = False
                     can_update_db_record = True
                 if can_update_db_record:
                     # The database record for the tool shed repository currently being processed can be updated.
                     # Get the repository metadata to see where it was previously located in the tool panel.
                     tpm = tool_panel_manager.ToolPanelManager( self.app )
                     if repository_db_record and repository_db_record.metadata:
                         tool_section, tool_panel_section_key = \
                             tpm.handle_tool_panel_selection( toolbox=self.app.toolbox,
                                                              metadata=repository_db_record.metadata,
                                                              no_changes_checked=no_changes_checked,
                                                              tool_panel_section_id=tool_panel_section_id,
                                                              new_tool_panel_section_label=new_tool_panel_section_label )
                     else:
                         # We're installing a new tool shed repository that does not yet have a database record.
                         tool_panel_section_key, tool_section = \
                             tpm.handle_tool_panel_section( self.app.toolbox,
                                                            tool_panel_section_id=tool_panel_section_id,
                                                            new_tool_panel_section_label=new_tool_panel_section_label )
                     tool_shed_repository = \
                         suc.create_or_update_tool_shed_repository( app=self.app,
                                                                    name=name,
                                                                    description=description,
                                                                    installed_changeset_revision=installed_changeset_revision,
                                                                    ctx_rev=ctx_rev,
                                                                    repository_clone_url=repository_clone_url,
                                                                    metadata_dict={},
                                                                    status=install_model.ToolShedRepository.installation_status.NEW,
                                                                    current_changeset_revision=changeset_revision,
                                                                    owner=repository_owner,
                                                                    dist_to_shed=False )
                     if tool_shed_repository not in all_created_or_updated_tool_shed_repositories:
                         all_created_or_updated_tool_shed_repositories.append( tool_shed_repository )
                     # Only append the tool shed repository to the list of created_or_updated_tool_shed_repositories if
                     # it is supposed to be installed.
                     if install_repository_dependencies or self.is_in_repo_info_dicts( repo_info_dict, repo_info_dicts ):
                         if tool_shed_repository not in created_or_updated_tool_shed_repositories:
                             # Keep the one-to-one mapping between items in 3 lists.
                             created_or_updated_tool_shed_repositories.append( tool_shed_repository )
                             tool_panel_section_keys.append( tool_panel_section_key )
                             filtered_repo_info_dicts.append( repo_info_dict )
     # Build repository dependency relationships even if the user chose to not install repository dependencies.
     self.build_repository_dependency_relationships( all_repo_info_dicts, all_created_or_updated_tool_shed_repositories )
     return created_or_updated_tool_shed_repositories, tool_panel_section_keys, all_repo_info_dicts, filtered_repo_info_dicts
Example #4
0
 def populate_tool_dependencies_dicts(
         self, tool_shed_url, tool_path,
         repository_installed_tool_dependencies,
         repository_missing_tool_dependencies, required_repo_info_dicts):
     """
     Return the populated installed_tool_dependencies and missing_tool_dependencies dictionaries
     for all repositories defined by entries in the received required_repo_info_dicts.
     """
     installed_tool_dependencies = None
     missing_tool_dependencies = None
     if repository_installed_tool_dependencies is None:
         repository_installed_tool_dependencies = {}
     else:
         # Add the install_dir attribute to the tool_dependencies.
         repository_installed_tool_dependencies = \
             self.add_installation_directories_to_tool_dependencies( repository_installed_tool_dependencies )
     if repository_missing_tool_dependencies is None:
         repository_missing_tool_dependencies = {}
     else:
         # Add the install_dir attribute to the tool_dependencies.
         repository_missing_tool_dependencies = \
             self.add_installation_directories_to_tool_dependencies( repository_missing_tool_dependencies )
     if required_repo_info_dicts:
         # Handle the tool dependencies defined for each of the repository's repository dependencies.
         for rid in required_repo_info_dicts:
             for name, repo_info_tuple in rid.items():
                 description, repository_clone_url, changeset_revision, \
                     ctx_rev, repository_owner, repository_dependencies, \
                     tool_dependencies = \
                     suc.get_repo_info_tuple_contents( repo_info_tuple )
                 if tool_dependencies:
                     # Add the install_dir attribute to the tool_dependencies.
                     tool_dependencies = self.add_installation_directories_to_tool_dependencies(
                         tool_dependencies)
                     # The required_repository may have been installed with a different changeset revision.
                     required_repository, installed_changeset_revision = \
                         suc.repository_was_previously_installed( self.app,
                                                                  tool_shed_url,
                                                                  name,
                                                                  repo_info_tuple,
                                                                  from_tip=False )
                     if required_repository:
                         required_repository_installed_tool_dependencies, required_repository_missing_tool_dependencies = \
                             self.get_installed_and_missing_tool_dependencies_for_installed_repository( required_repository,
                                                                                                        tool_dependencies )
                         if required_repository_installed_tool_dependencies:
                             # Add the install_dir attribute to the tool_dependencies.
                             required_repository_installed_tool_dependencies = \
                                 self.add_installation_directories_to_tool_dependencies( required_repository_installed_tool_dependencies )
                             for td_key, td_dict in required_repository_installed_tool_dependencies.items(
                             ):
                                 if td_key not in repository_installed_tool_dependencies:
                                     repository_installed_tool_dependencies[
                                         td_key] = td_dict
                         if required_repository_missing_tool_dependencies:
                             # Add the install_dir attribute to the tool_dependencies.
                             required_repository_missing_tool_dependencies = \
                                 self.add_installation_directories_to_tool_dependencies( required_repository_missing_tool_dependencies )
                             for td_key, td_dict in required_repository_missing_tool_dependencies.items(
                             ):
                                 if td_key not in repository_missing_tool_dependencies:
                                     repository_missing_tool_dependencies[
                                         td_key] = td_dict
     if repository_installed_tool_dependencies:
         installed_tool_dependencies = repository_installed_tool_dependencies
     if repository_missing_tool_dependencies:
         missing_tool_dependencies = repository_missing_tool_dependencies
     return installed_tool_dependencies, missing_tool_dependencies
 def create_repository_dependency_objects( self, tool_path, tool_shed_url, repo_info_dicts, install_repository_dependencies=False,
                                           no_changes_checked=False, tool_panel_section_id=None, new_tool_panel_section_label=None ):
     """
     Discover all repository dependencies and make sure all tool_shed_repository and
     associated repository_dependency records exist as well as the dependency relationships
     between installed repositories.  This method is called when uninstalled repositories
     are being reinstalled.  If the user elected to install repository dependencies, all
     items in the all_repo_info_dicts list will be processed.  However, if repository
     dependencies are not to be installed, only those items contained in the received
     repo_info_dicts list will be processed.
     """
     install_model = self.app.install_model
     log.debug( "Creating repository dependency objects..." )
     # The following list will be maintained within this method to contain all created
     # or updated tool shed repositories, including repository dependencies that may not
     # be installed.
     all_created_or_updated_tool_shed_repositories = []
     # There will be a one-to-one mapping between items in 3 lists:
     # created_or_updated_tool_shed_repositories, tool_panel_section_keys
     # and filtered_repo_info_dicts.  The 3 lists will filter out repository
     # dependencies that are not to be installed.
     created_or_updated_tool_shed_repositories = []
     tool_panel_section_keys = []
     # Repositories will be filtered (e.g., if already installed, if elected
     # to not be installed, etc), so filter the associated repo_info_dicts accordingly.
     filtered_repo_info_dicts = []
     # Discover all repository dependencies and retrieve information for installing
     # them.  Even if the user elected to not install repository dependencies we have
     # to make sure all repository dependency objects exist so that the appropriate
     # repository dependency relationships can be built.
     all_required_repo_info_dict = self.get_required_repo_info_dicts( tool_shed_url, repo_info_dicts )
     all_repo_info_dicts = all_required_repo_info_dict.get( 'all_repo_info_dicts', [] )
     if not all_repo_info_dicts:
         # No repository dependencies were discovered so process the received repositories.
         all_repo_info_dicts = [ rid for rid in repo_info_dicts ]
     for repo_info_dict in all_repo_info_dicts:
         # If the user elected to install repository dependencies, all items in the
         # all_repo_info_dicts list will be processed.  However, if repository dependencies
         # are not to be installed, only those items contained in the received repo_info_dicts
         # list will be processed but the all_repo_info_dicts list will be used to create all
         # defined repository dependency relationships.
         if self.is_in_repo_info_dicts( repo_info_dict, repo_info_dicts ) or install_repository_dependencies:
             for name, repo_info_tuple in repo_info_dict.items():
                 can_update_db_record = False
                 description, \
                     repository_clone_url, \
                     changeset_revision, \
                     ctx_rev, \
                     repository_owner, \
                     repository_dependencies, \
                     tool_dependencies = \
                     suc.get_repo_info_tuple_contents( repo_info_tuple )
                 # See if the repository has an existing record in the database.
                 repository_db_record, installed_changeset_revision = \
                     suc.repository_was_previously_installed( self.app, tool_shed_url, name, repo_info_tuple, from_tip=False )
                 if repository_db_record:
                     if repository_db_record.status in [ install_model.ToolShedRepository.installation_status.INSTALLED,
                                                         install_model.ToolShedRepository.installation_status.CLONING,
                                                         install_model.ToolShedRepository.installation_status.SETTING_TOOL_VERSIONS,
                                                         install_model.ToolShedRepository.installation_status.INSTALLING_REPOSITORY_DEPENDENCIES,
                                                         install_model.ToolShedRepository.installation_status.INSTALLING_TOOL_DEPENDENCIES,
                                                         install_model.ToolShedRepository.installation_status.LOADING_PROPRIETARY_DATATYPES ]:
                         debug_msg = "Skipping installation of revision %s of repository '%s' because it was installed " % \
                             ( str( changeset_revision ), str( repository_db_record.name ) )
                         debug_msg += "with the (possibly updated) revision %s and its current installation status is '%s'." % \
                             ( str( installed_changeset_revision ), str( repository_db_record.status ) )
                         log.debug( debug_msg )
                         can_update_db_record = False
                     else:
                         if repository_db_record.status in [ install_model.ToolShedRepository.installation_status.ERROR,
                                                             install_model.ToolShedRepository.installation_status.NEW,
                                                             install_model.ToolShedRepository.installation_status.UNINSTALLED ]:
                             # The current tool shed repository is not currently installed, so we can update its
                             # record in the database.
                             name = repository_db_record.name
                             installed_changeset_revision = repository_db_record.installed_changeset_revision
                             can_update_db_record = True
                         elif repository_db_record.status in [ install_model.ToolShedRepository.installation_status.DEACTIVATED ]:
                             # The current tool shed repository is deactivated, so updating its database record
                             # is not necessary - just activate it.
                             log.debug( "Reactivating deactivated tool_shed_repository '%s'." % str( repository_db_record.name ) )
                             self.app.installed_repository_manager.activate_repository( repository_db_record )
                             # No additional updates to the database record are necessary.
                             can_update_db_record = False
                         elif repository_db_record.status not in [ install_model.ToolShedRepository.installation_status.NEW ]:
                             # Set changeset_revision here so suc.create_or_update_tool_shed_repository will find
                             # the previously installed and uninstalled repository instead of creating a new record.
                             changeset_revision = repository_db_record.installed_changeset_revision
                             self.reset_previously_installed_repository( repository_db_record )
                             can_update_db_record = True
                 else:
                     # No record exists in the database for the repository currently being processed.
                     installed_changeset_revision = changeset_revision
                     can_update_db_record = True
                 if can_update_db_record:
                     # The database record for the tool shed repository currently being processed can be updated.
                     # Get the repository metadata to see where it was previously located in the tool panel.
                     tpm = tool_panel_manager.ToolPanelManager( self.app )
                     if repository_db_record and repository_db_record.metadata:
                         _, tool_panel_section_key = \
                             tpm.handle_tool_panel_selection( toolbox=self.app.toolbox,
                                                              metadata=repository_db_record.metadata,
                                                              no_changes_checked=no_changes_checked,
                                                              tool_panel_section_id=tool_panel_section_id,
                                                              new_tool_panel_section_label=new_tool_panel_section_label )
                     else:
                         # We're installing a new tool shed repository that does not yet have a database record.
                         tool_panel_section_key, _ = \
                             tpm.handle_tool_panel_section( self.app.toolbox,
                                                            tool_panel_section_id=tool_panel_section_id,
                                                            new_tool_panel_section_label=new_tool_panel_section_label )
                     tool_shed_repository = \
                         suc.create_or_update_tool_shed_repository( app=self.app,
                                                                    name=name,
                                                                    description=description,
                                                                    installed_changeset_revision=installed_changeset_revision,
                                                                    ctx_rev=ctx_rev,
                                                                    repository_clone_url=repository_clone_url,
                                                                    metadata_dict={},
                                                                    status=install_model.ToolShedRepository.installation_status.NEW,
                                                                    current_changeset_revision=changeset_revision,
                                                                    owner=repository_owner,
                                                                    dist_to_shed=False )
                     if tool_shed_repository not in all_created_or_updated_tool_shed_repositories:
                         all_created_or_updated_tool_shed_repositories.append( tool_shed_repository )
                     # Only append the tool shed repository to the list of created_or_updated_tool_shed_repositories if
                     # it is supposed to be installed.
                     if install_repository_dependencies or self.is_in_repo_info_dicts( repo_info_dict, repo_info_dicts ):
                         if tool_shed_repository not in created_or_updated_tool_shed_repositories:
                             # Keep the one-to-one mapping between items in 3 lists.
                             created_or_updated_tool_shed_repositories.append( tool_shed_repository )
                             tool_panel_section_keys.append( tool_panel_section_key )
                             filtered_repo_info_dicts.append( repo_info_dict )
     # Build repository dependency relationships even if the user chose to not install repository dependencies.
     self.build_repository_dependency_relationships( all_repo_info_dicts, all_created_or_updated_tool_shed_repositories )
     return created_or_updated_tool_shed_repositories, tool_panel_section_keys, all_repo_info_dicts, filtered_repo_info_dicts
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