コード例 #1
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 = 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,
                status=self.app.install_model.ToolShedRepository.
                installation_status.NEW,
                metadata_dict={},
                current_changeset_revision=None,
                owner=self.repository_owner,
                dist_to_shed=True)
            return tool_shed_repository
        return None
コード例 #2
0
 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 = repository_util.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 = get_ctx_rev(self.app, tool_shed_url, name, owner,
                               changeset_revision)
         repository = repository_util.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,
             status=install_model.ToolShedRepository.installation_status.
             NEW,
             metadata_dict={},
             current_changeset_revision=None,
             owner=owner,
             dist_to_shed=False)
     return repository
コード例 #3
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 = 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', tool_shed_repository.name, error_message)
             irm.update_tool_shed_repository_status(tool_shed_repository,
                                                    self.app.install_model.ToolShedRepository.installation_status.ERROR,
                                                    error_message=error_message)