def get_or_create_tool_shed_repository( self, tool_shed, name, owner, changeset_revision ):
     """
     Return a tool shed repository database record defined by the combination of
     tool shed, repository name, repository owner and changeset_revision or
     installed_changeset_revision.  A new tool shed repository record will be
     created if one is not located.
     """
     install_model = self.app.install_model
     # We store the port in the database.
     tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed )
     # This method is used only in Galaxy, not the tool shed.
     repository = suc.get_repository_for_dependency_relationship( self.app, tool_shed, name, owner, changeset_revision )
     if not repository:
         tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( self.app, tool_shed )
         repository_clone_url = os.path.join( tool_shed_url, 'repos', owner, name )
         ctx_rev = suc.get_ctx_rev( self.app, tool_shed_url, name, owner, changeset_revision )
         repository = suc.create_or_update_tool_shed_repository( app=self.app,
                                                                 name=name,
                                                                 description=None,
                                                                 installed_changeset_revision=changeset_revision,
                                                                 ctx_rev=ctx_rev,
                                                                 repository_clone_url=repository_clone_url,
                                                                 metadata_dict={},
                                                                 status=install_model.ToolShedRepository.installation_status.NEW,
                                                                 current_changeset_revision=None,
                                                                 owner=owner,
                                                                 dist_to_shed=False )
     return repository
Example #2
0
    def create_or_update_tool_shed_repository_record(self,
                                                     name,
                                                     owner,
                                                     changeset_revision,
                                                     description=None):

        # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<installed changeset revision>
        relative_clone_dir = os.path.join(self.tool_shed, 'repos', owner, name,
                                          changeset_revision)
        clone_dir = os.path.join(self.tool_path, relative_clone_dir)
        if not self.__iscloned(clone_dir):
            repository_clone_url = os.path.join(self.tool_shed_url, 'repos',
                                                owner, name)
            ctx_rev = suc.get_ctx_rev(self.app, self.tool_shed_url, name,
                                      owner, changeset_revision)
            tool_shed_repository = repository_util.create_or_update_tool_shed_repository(
                app=self.app,
                name=name,
                description=description,
                installed_changeset_revision=changeset_revision,
                ctx_rev=ctx_rev,
                repository_clone_url=repository_clone_url,
                metadata_dict={},
                status=self.app.install_model.ToolShedRepository.
                installation_status.NEW,
                current_changeset_revision=None,
                owner=self.repository_owner,
                dist_to_shed=True)
            return tool_shed_repository
        return None
 def get_or_create_tool_shed_repository( self, tool_shed, name, owner, changeset_revision ):
     """
     Return a tool shed repository database record defined by the combination of
     tool shed, repository name, repository owner and changeset_revision or
     installed_changeset_revision.  A new tool shed repository record will be
     created if one is not located.
     """
     install_model = self.app.install_model
     # We store the port in the database.
     tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed )
     # This method is used only in Galaxy, not the tool shed.
     repository = suc.get_repository_for_dependency_relationship( self.app, tool_shed, name, owner, changeset_revision )
     if not repository:
         tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( self.app, tool_shed )
         repository_clone_url = os.path.join( tool_shed_url, 'repos', owner, name )
         ctx_rev = suc.get_ctx_rev( self.app, tool_shed_url, name, owner, changeset_revision )
         repository = suc.create_or_update_tool_shed_repository( app=self.app,
                                                                 name=name,
                                                                 description=None,
                                                                 installed_changeset_revision=changeset_revision,
                                                                 ctx_rev=ctx_rev,
                                                                 repository_clone_url=repository_clone_url,
                                                                 metadata_dict={},
                                                                 status=install_model.ToolShedRepository.installation_status.NEW,
                                                                 current_changeset_revision=None,
                                                                 owner=owner,
                                                                 dist_to_shed=False )
     return repository
 def install_repository(self, repository_elem, tool_shed_repository, install_dependencies, is_repository_dependency=False):
     """Install a single repository, loading contained tools into the tool panel."""
     # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<installed changeset revision>
     relative_clone_dir = os.path.join(tool_shed_repository.tool_shed,
                                       'repos',
                                       tool_shed_repository.owner,
                                       tool_shed_repository.name,
                                       tool_shed_repository.installed_changeset_revision)
     clone_dir = os.path.join(self.tool_path, relative_clone_dir)
     cloned_ok = self.__iscloned(clone_dir)
     is_installed = False
     # Any of the following states should count as installed in this context.
     if tool_shed_repository.status in [self.app.install_model.ToolShedRepository.installation_status.INSTALLED,
                                        self.app.install_model.ToolShedRepository.installation_status.ERROR,
                                        self.app.install_model.ToolShedRepository.installation_status.UNINSTALLED,
                                        self.app.install_model.ToolShedRepository.installation_status.DEACTIVATED]:
         is_installed = True
     if cloned_ok and is_installed:
         log.info("Skipping automatic install of repository '%s' because it has already been installed in location %s",
                  tool_shed_repository.name, clone_dir)
     else:
         irm = install_manager.InstallRepositoryManager(self.app, self.tpm)
         repository_clone_url = os.path.join(self.tool_shed_url, 'repos', tool_shed_repository.owner, tool_shed_repository.name)
         relative_install_dir = os.path.join(relative_clone_dir, tool_shed_repository.name)
         install_dir = os.path.join(clone_dir, tool_shed_repository.name)
         ctx_rev = suc.get_ctx_rev(self.app,
                                   self.tool_shed_url,
                                   tool_shed_repository.name,
                                   tool_shed_repository.owner,
                                   tool_shed_repository.installed_changeset_revision)
         if not cloned_ok:
             irm.update_tool_shed_repository_status(tool_shed_repository,
                                                    self.app.install_model.ToolShedRepository.installation_status.CLONING)
             cloned_ok, error_message = hg_util.clone_repository(repository_clone_url, os.path.abspath(install_dir), ctx_rev)
         if cloned_ok and not is_installed:
             self.handle_repository_contents(tool_shed_repository=tool_shed_repository,
                                             repository_clone_url=repository_clone_url,
                                             relative_install_dir=relative_install_dir,
                                             repository_elem=repository_elem,
                                             install_dependencies=install_dependencies,
                                             is_repository_dependency=is_repository_dependency)
             self.app.install_model.context.refresh(tool_shed_repository)
             irm.update_tool_shed_repository_status(tool_shed_repository,
                                                    self.app.install_model.ToolShedRepository.installation_status.INSTALLED)
         else:
             log.error('Error attempting to clone repository %s: %s', str(tool_shed_repository.name), str(error_message))
             irm.update_tool_shed_repository_status(tool_shed_repository,
                                                    self.app.install_model.ToolShedRepository.installation_status.ERROR,
                                                    error_message=error_message)
Example #5
0
    def create_or_update_tool_shed_repository_record( self, name, owner, changeset_revision, description=None ):

        # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<installed changeset revision>
        relative_clone_dir = os.path.join( self.tool_shed, 'repos', owner, name, changeset_revision )
        clone_dir = os.path.join( self.tool_path, relative_clone_dir )
        if not self.__iscloned( clone_dir ):
            repository_clone_url = os.path.join( self.tool_shed_url, 'repos', owner, name )
            ctx_rev = suc.get_ctx_rev( self.app, self.tool_shed_url, name, owner, changeset_revision )
            tool_shed_repository = suc.create_or_update_tool_shed_repository( app=self.app,
                                                                              name=name,
                                                                              description=description,
                                                                              installed_changeset_revision=changeset_revision,
                                                                              ctx_rev=ctx_rev,
                                                                              repository_clone_url=repository_clone_url,
                                                                              metadata_dict={},
                                                                              status=self.app.install_model.ToolShedRepository.installation_status.NEW,
                                                                              current_changeset_revision=None,
                                                                              owner=self.repository_owner,
                                                                              dist_to_shed=True )
            return tool_shed_repository
        return None
 def install_repository( self, repository_elem, tool_shed_repository, install_dependencies, is_repository_dependency=False ):
     """Install a single repository, loading contained tools into the tool panel."""
     # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<installed changeset revision>
     relative_clone_dir = os.path.join( tool_shed_repository.tool_shed,
                                        'repos',
                                        tool_shed_repository.owner,
                                        tool_shed_repository.name,
                                        tool_shed_repository.installed_changeset_revision )
     clone_dir = os.path.join( self.tool_path, relative_clone_dir )
     cloned_ok = self.__iscloned( clone_dir )
     is_installed = False
     # Any of the following states should count as installed in this context.
     if tool_shed_repository.status in [ self.app.install_model.ToolShedRepository.installation_status.INSTALLED,
                                         self.app.install_model.ToolShedRepository.installation_status.ERROR,
                                         self.app.install_model.ToolShedRepository.installation_status.UNINSTALLED,
                                         self.app.install_model.ToolShedRepository.installation_status.DEACTIVATED ]:
         is_installed = True
     if cloned_ok and is_installed:
         print "Skipping automatic install of repository '", tool_shed_repository.name, "' because it has already been installed in location ", clone_dir
     else:
         irm = install_manager.InstallRepositoryManager( self.app, self.tpm )
         repository_clone_url = os.path.join( self.tool_shed_url, 'repos', tool_shed_repository.owner, tool_shed_repository.name )
         relative_install_dir = os.path.join( relative_clone_dir, tool_shed_repository.name )
         install_dir = os.path.join( clone_dir, tool_shed_repository.name )
         ctx_rev = suc.get_ctx_rev( self.app,
                                    self.tool_shed_url,
                                    tool_shed_repository.name,
                                    tool_shed_repository.owner,
                                    tool_shed_repository.installed_changeset_revision )
         if not cloned_ok:
             irm.update_tool_shed_repository_status( tool_shed_repository,
                                                     self.app.install_model.ToolShedRepository.installation_status.CLONING )
             cloned_ok, error_message = hg_util.clone_repository( repository_clone_url, os.path.abspath( install_dir ), ctx_rev )
         if cloned_ok and not is_installed:
             self.handle_repository_contents( tool_shed_repository=tool_shed_repository,
                                              repository_clone_url=repository_clone_url,
                                              relative_install_dir=relative_install_dir,
                                              repository_elem=repository_elem,
                                              install_dependencies=install_dependencies,
                                              is_repository_dependency=is_repository_dependency )
             self.app.install_model.context.refresh( tool_shed_repository )
             metadata_dict = tool_shed_repository.metadata
             if 'tools' in metadata_dict:
                 # Initialize the ToolVersionManager.
                 tvm = tool_version_manager.ToolVersionManager( self.app )
                 irm.update_tool_shed_repository_status( tool_shed_repository,
                                                         self.app.install_model.ToolShedRepository.installation_status.SETTING_TOOL_VERSIONS )
                 # Get the tool_versions from the tool shed for each tool in the installed change set.
                 url = '%s/repository/get_tool_versions?name=%s&owner=%s&changeset_revision=%s' % \
                     ( self.tool_shed_url, tool_shed_repository.name, self.repository_owner, tool_shed_repository.installed_changeset_revision )
                 text = common_util.tool_shed_get( self.app, self.tool_shed_url, url )
                 if text:
                     tool_version_dicts = json.loads( text )
                     tvm.handle_tool_versions( tool_version_dicts, tool_shed_repository )
                 else:
                     # Set the tool versions since they seem to be missing for this repository in the tool shed.
                     # CRITICAL NOTE: These default settings may not properly handle all parent/child associations.
                     for tool_dict in metadata_dict[ 'tools' ]:
                         flush_needed = False
                         tool_id = tool_dict[ 'guid' ]
                         old_tool_id = tool_dict[ 'id' ]
                         tool_version = tool_dict[ 'version' ]
                         tool_version_using_old_id = tvm.get_tool_version( old_tool_id )
                         tool_version_using_guid = tvm.get_tool_version( tool_id )
                         if not tool_version_using_old_id:
                             tool_version_using_old_id = self.app.install_model.ToolVersion( tool_id=old_tool_id,
                                                                                     tool_shed_repository=tool_shed_repository )
                             self.app.install_model.context.add( tool_version_using_old_id )
                             self.app.install_model.context.flush()
                         if not tool_version_using_guid:
                             tool_version_using_guid = self.app.install_model.ToolVersion( tool_id=tool_id,
                                                                                   tool_shed_repository=tool_shed_repository )
                             self.app.install_model.context.add( tool_version_using_guid )
                             self.app.install_model.context.flush()
                         # Associate the two versions as parent / child.
                         tool_version_association = tvm.get_tool_version_association( tool_version_using_old_id,
                                                                                      tool_version_using_guid )
                         if not tool_version_association:
                             tool_version_association = \
                                 self.app.install_model.ToolVersionAssociation( tool_id=tool_version_using_guid.id,
                                                                                parent_id=tool_version_using_old_id.id )
                             self.app.install_model.context.add( tool_version_association )
                             self.app.install_model.context.flush()
             irm.update_tool_shed_repository_status( tool_shed_repository,
                                                     self.app.install_model.ToolShedRepository.installation_status.INSTALLED )
         else:
             print 'Error attempting to clone repository %s: %s' % ( str( tool_shed_repository.name ), str( error_message ) )
             irm.update_tool_shed_repository_status( tool_shed_repository,
                                                     self.app.install_model.ToolShedRepository.installation_status.ERROR,
                                                     error_message=error_message )
Example #7
0
 def install_repository(self,
                        repository_elem,
                        tool_shed_repository,
                        install_dependencies,
                        is_repository_dependency=False):
     """Install a single repository, loading contained tools into the tool panel."""
     # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<installed changeset revision>
     relative_clone_dir = os.path.join(
         tool_shed_repository.tool_shed, 'repos',
         tool_shed_repository.owner, tool_shed_repository.name,
         tool_shed_repository.installed_changeset_revision)
     clone_dir = os.path.join(self.tool_path, relative_clone_dir)
     cloned_ok = self.__iscloned(clone_dir)
     is_installed = False
     # Any of the following states should count as installed in this context.
     if tool_shed_repository.status in [
             self.app.install_model.ToolShedRepository.installation_status.
             INSTALLED, self.app.install_model.ToolShedRepository.
             installation_status.ERROR, self.app.install_model.
             ToolShedRepository.installation_status.UNINSTALLED,
             self.app.install_model.ToolShedRepository.installation_status.
             DEACTIVATED
     ]:
         is_installed = True
     if cloned_ok and is_installed:
         log.info(
             "Skipping automatic install of repository '%s' because it has already been installed in location %s",
             tool_shed_repository.name, clone_dir)
     else:
         irm = install_manager.InstallRepositoryManager(self.app, self.tpm)
         repository_clone_url = os.path.join(self.tool_shed_url, 'repos',
                                             tool_shed_repository.owner,
                                             tool_shed_repository.name)
         relative_install_dir = os.path.join(relative_clone_dir,
                                             tool_shed_repository.name)
         install_dir = os.path.join(clone_dir, tool_shed_repository.name)
         ctx_rev = suc.get_ctx_rev(
             self.app, self.tool_shed_url, tool_shed_repository.name,
             tool_shed_repository.owner,
             tool_shed_repository.installed_changeset_revision)
         if not cloned_ok:
             irm.update_tool_shed_repository_status(
                 tool_shed_repository, self.app.install_model.
                 ToolShedRepository.installation_status.CLONING)
             cloned_ok, error_message = hg_util.clone_repository(
                 repository_clone_url, os.path.abspath(install_dir),
                 ctx_rev)
         if cloned_ok and not is_installed:
             self.handle_repository_contents(
                 tool_shed_repository=tool_shed_repository,
                 repository_clone_url=repository_clone_url,
                 relative_install_dir=relative_install_dir,
                 repository_elem=repository_elem,
                 install_dependencies=install_dependencies,
                 is_repository_dependency=is_repository_dependency)
             self.app.install_model.context.refresh(tool_shed_repository)
             irm.update_tool_shed_repository_status(
                 tool_shed_repository, self.app.install_model.
                 ToolShedRepository.installation_status.INSTALLED)
         else:
             log.error('Error attempting to clone repository %s: %s',
                       str(tool_shed_repository.name), str(error_message))
             irm.update_tool_shed_repository_status(
                 tool_shed_repository,
                 self.app.install_model.ToolShedRepository.
                 installation_status.ERROR,
                 error_message=error_message)
 def install_repository(self,
                        repository_elem,
                        tool_shed_repository,
                        install_dependencies,
                        is_repository_dependency=False):
     """Install a single repository, loading contained tools into the tool panel."""
     # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<installed changeset revision>
     relative_clone_dir = os.path.join(
         tool_shed_repository.tool_shed, 'repos',
         tool_shed_repository.owner, tool_shed_repository.name,
         tool_shed_repository.installed_changeset_revision)
     clone_dir = os.path.join(self.tool_path, relative_clone_dir)
     cloned_ok = self.__iscloned(clone_dir)
     is_installed = False
     # Any of the following states should count as installed in this context.
     if tool_shed_repository.status in [
             self.app.install_model.ToolShedRepository.installation_status.
             INSTALLED, self.app.install_model.ToolShedRepository.
             installation_status.ERROR, self.app.install_model.
             ToolShedRepository.installation_status.UNINSTALLED,
             self.app.install_model.ToolShedRepository.installation_status.
             DEACTIVATED
     ]:
         is_installed = True
     if cloned_ok and is_installed:
         log.info(
             "Skipping automatic install of repository '%s' because it has already been installed in location %s",
             tool_shed_repository.name, clone_dir)
     else:
         irm = install_manager.InstallRepositoryManager(self.app, self.tpm)
         repository_clone_url = os.path.join(self.tool_shed_url, 'repos',
                                             tool_shed_repository.owner,
                                             tool_shed_repository.name)
         relative_install_dir = os.path.join(relative_clone_dir,
                                             tool_shed_repository.name)
         install_dir = os.path.join(clone_dir, tool_shed_repository.name)
         ctx_rev = suc.get_ctx_rev(
             self.app, self.tool_shed_url, tool_shed_repository.name,
             tool_shed_repository.owner,
             tool_shed_repository.installed_changeset_revision)
         if not cloned_ok:
             irm.update_tool_shed_repository_status(
                 tool_shed_repository, self.app.install_model.
                 ToolShedRepository.installation_status.CLONING)
             cloned_ok, error_message = hg_util.clone_repository(
                 repository_clone_url, os.path.abspath(install_dir),
                 ctx_rev)
         if cloned_ok and not is_installed:
             self.handle_repository_contents(
                 tool_shed_repository=tool_shed_repository,
                 repository_clone_url=repository_clone_url,
                 relative_install_dir=relative_install_dir,
                 repository_elem=repository_elem,
                 install_dependencies=install_dependencies,
                 is_repository_dependency=is_repository_dependency)
             self.app.install_model.context.refresh(tool_shed_repository)
             metadata_dict = tool_shed_repository.metadata
             if 'tools' in metadata_dict:
                 # Initialize the ToolVersionManager.
                 tvm = tool_version_manager.ToolVersionManager(self.app)
                 irm.update_tool_shed_repository_status(
                     tool_shed_repository,
                     self.app.install_model.ToolShedRepository.
                     installation_status.SETTING_TOOL_VERSIONS)
                 # Get the tool_versions from the tool shed for each tool in the installed change set.
                 params = dict(name=tool_shed_repository.name,
                               owner=self.repository_owner,
                               changeset_revision=tool_shed_repository.
                               installed_changeset_revision)
                 pathspec = ['repository', 'get_tool_versions']
                 text = util.url_get(
                     self.tool_shed_url,
                     password_mgr=self.app.tool_shed_registry.url_auth(
                         self.tool_shed_url),
                     pathspec=pathspec,
                     params=params)
                 if text:
                     tool_version_dicts = json.loads(text)
                     tvm.handle_tool_versions(tool_version_dicts,
                                              tool_shed_repository)
                 else:
                     # Set the tool versions since they seem to be missing
                     # for this repository in the tool shed. CRITICAL NOTE:
                     # These default settings may not properly handle all
                     # parent/child associations.
                     for tool_dict in metadata_dict['tools']:
                         tool_id = tool_dict['guid']
                         old_tool_id = tool_dict['id']
                         tool_version_using_old_id = tvm.get_tool_version(
                             old_tool_id)
                         tool_version_using_guid = tvm.get_tool_version(
                             tool_id)
                         if not tool_version_using_old_id:
                             tool_version_using_old_id = self.app.install_model.ToolVersion(
                                 tool_id=old_tool_id,
                                 tool_shed_repository=tool_shed_repository)
                             self.app.install_model.context.add(
                                 tool_version_using_old_id)
                             self.app.install_model.context.flush()
                         if not tool_version_using_guid:
                             tool_version_using_guid = self.app.install_model.ToolVersion(
                                 tool_id=tool_id,
                                 tool_shed_repository=tool_shed_repository)
                             self.app.install_model.context.add(
                                 tool_version_using_guid)
                             self.app.install_model.context.flush()
                         # Associate the two versions as parent / child.
                         tool_version_association = tvm.get_tool_version_association(
                             tool_version_using_old_id,
                             tool_version_using_guid)
                         if not tool_version_association:
                             tool_version_association = \
                                 self.app.install_model.ToolVersionAssociation( tool_id=tool_version_using_guid.id,
                                                                                parent_id=tool_version_using_old_id.id )
                             self.app.install_model.context.add(
                                 tool_version_association)
                             self.app.install_model.context.flush()
             irm.update_tool_shed_repository_status(
                 tool_shed_repository, self.app.install_model.
                 ToolShedRepository.installation_status.INSTALLED)
         else:
             log.error('Error attempting to clone repository %s: %s',
                       str(tool_shed_repository.name), str(error_message))
             irm.update_tool_shed_repository_status(
                 tool_shed_repository,
                 self.app.install_model.ToolShedRepository.
                 installation_status.ERROR,
                 error_message=error_message)
Example #9
0
 def install_repository( self, repository_elem, install_dependencies ):
     # Install a single repository, loading contained tools into the tool panel.
     name = repository_elem.get( 'name' )
     description = repository_elem.get( 'description' )
     installed_changeset_revision = repository_elem.get( 'changeset_revision' )
     # Install path is of the form: <tool path>/<tool shed>/repos/<repository owner>/<repository name>/<installed changeset revision>
     relative_clone_dir = os.path.join( self.tool_shed, 'repos', self.repository_owner, name, installed_changeset_revision )
     clone_dir = os.path.join( self.tool_path, relative_clone_dir )
     if self.__isinstalled( clone_dir ):
         print "Skipping automatic install of repository '", name, "' because it has already been installed in location ", clone_dir
     else:
         tool_shed_url = suc.get_url_from_tool_shed( self.app, self.tool_shed )
         repository_clone_url = os.path.join( tool_shed_url, 'repos', self.repository_owner, name )
         relative_install_dir = os.path.join( relative_clone_dir, name )
         install_dir = os.path.join( clone_dir, name )
         ctx_rev = suc.get_ctx_rev( self.app, tool_shed_url, name, self.repository_owner, installed_changeset_revision )
         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=self.app.model.ToolShedRepository.installation_status.NEW,
                                                                           current_changeset_revision=None,
                                                                           owner=self.repository_owner,
                                                                           dist_to_shed=True )
         suc.update_tool_shed_repository_status( self.app, tool_shed_repository, self.app.model.ToolShedRepository.installation_status.CLONING )
         cloned_ok, error_message = suc.clone_repository( repository_clone_url, os.path.abspath( install_dir ), ctx_rev )
         if cloned_ok:
             self.handle_repository_contents( tool_shed_repository=tool_shed_repository,
                                              repository_clone_url=repository_clone_url,
                                              relative_install_dir=relative_install_dir,
                                              repository_elem=repository_elem,
                                              install_dependencies=install_dependencies )
             self.app.sa_session.refresh( tool_shed_repository )
             metadata_dict = tool_shed_repository.metadata
             if 'tools' in metadata_dict:
                 suc.update_tool_shed_repository_status( self.app,
                                                         tool_shed_repository,
                                                         self.app.model.ToolShedRepository.installation_status.SETTING_TOOL_VERSIONS )
                 # Get the tool_versions from the tool shed for each tool in the installed change set.
                 url = '%s/repository/get_tool_versions?name=%s&owner=%s&changeset_revision=%s' % \
                     ( tool_shed_url, tool_shed_repository.name, self.repository_owner, installed_changeset_revision )
                 text = common_util.tool_shed_get( self.app, tool_shed_url, url )
                 if text:
                     tool_version_dicts = from_json_string( text )
                     tool_util.handle_tool_versions( self.app, tool_version_dicts, tool_shed_repository )
                 else:
                     # Set the tool versions since they seem to be missing for this repository in the tool shed.
                     # CRITICAL NOTE: These default settings may not properly handle all parent/child associations.
                     for tool_dict in metadata_dict[ 'tools' ]:
                         flush_needed = False
                         tool_id = tool_dict[ 'guid' ]
                         old_tool_id = tool_dict[ 'id' ]
                         tool_version = tool_dict[ 'version' ]
                         tool_version_using_old_id = tool_util.get_tool_version( self.app, old_tool_id )
                         tool_version_using_guid = tool_util.get_tool_version( self.app, tool_id )
                         if not tool_version_using_old_id:
                             tool_version_using_old_id = self.app.model.ToolVersion( tool_id=old_tool_id,
                                                                                     tool_shed_repository=tool_shed_repository )
                             self.app.sa_session.add( tool_version_using_old_id )
                             self.app.sa_session.flush()
                         if not tool_version_using_guid:
                             tool_version_using_guid = self.app.model.ToolVersion( tool_id=tool_id,
                                                                                   tool_shed_repository=tool_shed_repository )
                             self.app.sa_session.add( tool_version_using_guid )
                             self.app.sa_session.flush()
                         # Associate the two versions as parent / child.
                         tool_version_association = tool_util.get_tool_version_association( self.app,
                                                                                            tool_version_using_old_id,
                                                                                            tool_version_using_guid )
                         if not tool_version_association:
                             tool_version_association = self.app.model.ToolVersionAssociation( tool_id=tool_version_using_guid.id,
                                                                                               parent_id=tool_version_using_old_id.id )
                             self.app.sa_session.add( tool_version_association )
                             self.app.sa_session.flush()
             suc.update_tool_shed_repository_status( self.app, tool_shed_repository, self.app.model.ToolShedRepository.installation_status.INSTALLED )