Exemplo n.º 1
0
def _create_profile_local(ctx, profile_directory, profile_name, kwds):
    database_type = kwds.get("database_type", "auto")
    if database_type == "auto":
        if which("psql"):
            database_type = "postgres"
        elif which("docker"):
            database_type = "postgres_docker"
        else:
            database_type = "sqlite"

    if database_type != "sqlite":
        database_source = create_database_source(**kwds)
        database_identifier = _profile_to_database_identifier(profile_name)
        database_source.create_database(database_identifier, )
        database_connection = database_source.sqlalchemy_url(
            database_identifier)
    else:
        database_location = os.path.join(profile_directory, "galaxy.sqlite")
        database_connection = DATABASE_LOCATION_TEMPLATE % database_location

    return {
        "database_type": database_type,
        "database_connection": database_connection,
        "engine": "galaxy",
    }
Exemplo n.º 2
0
def find_engine(config):
    nodejs_path = getattr(config, "nodejs_path", None)
    if nodejs_path is None:
        nodejs_path = which("nodejs") or which("node") or None
    if nodejs_path is None:
        raise Exception("nodejs or node not found on PATH")
    return nodejs_path
def create_command(virtualenv_path, galaxy_python_version=None):
    """ If virtualenv is on Planemo's path use it, otherwise use the planemo
    subcommand virtualenv to create the virtualenv.
    """
    planemo_path = os.path.abspath(sys.argv[0])
    virtualenv_on_path = which("virtualenv")
    if virtualenv_on_path:
        base_command = [
            os.path.abspath(virtualenv_on_path),
        ]
    else:
        base_command = [
            planemo_path, "virtualenv",
        ]

    command = base_command

    # Create a virtualenv with the selected python version.
    # default to 2.7
    if galaxy_python_version is None:
        galaxy_python_version = DEFAULT_PYTHON_VERSION
    python = which("python%s" % galaxy_python_version)
    if python:
        python = os.path.abspath(python)
        command.extend(["-p", python])
    command.append(virtualenv_path)
    return " ".join(command)
Exemplo n.º 4
0
 def test_build_mulled(self):
     if not which('docker'):
         raise unittest.SkipTest(
             "Docker not found on PATH, required for building images via involucro"
         )
     resolver_type = self.build_mulled_resolver
     tool_ids = ['mulled_example_multi_1']
     endpoint = "dependency_resolvers/toolbox/install"
     data = {
         'tool_ids': json.dumps(tool_ids),
         'resolver_type': resolver_type,
         'container_type': self.container_type,
         'include_containers': True
     }
     create_response = self._post(endpoint, data=data, admin=True)
     self._assert_status_code_is(create_response, 200)
     create_response = self._get("dependency_resolvers/toolbox",
                                 data={
                                     'tool_ids': tool_ids,
                                     'container_type': self.container_type,
                                     'include_containers': True,
                                     'index_by': 'tools'
                                 },
                                 admin=True)
     response = create_response.json()
     assert len(response) == 1
     status = response[0]['status']
     assert status[0]['model_class'] == 'ContainerDependency'
     assert status[0]['dependency_type'] == self.container_type
     assert status[0]['container_description']['identifier'].startswith(
         'quay.io/local/mulled-v2-')
Exemplo n.º 5
0
def create_database_source(**kwds):
    """Return a :class:`planemo.database.DatabaseSource` for configuration."""
    database_type = kwds.get("database_type", "auto")
    if database_type == "auto":
        if which("psql"):
            database_type = "postgres"
        elif which("docker"):
            database_type = "postgres_docker"
        else:
            raise Exception(
                "Cannot find executables for psql or docker, cannot configure a database source."
            )

    if database_type == "postgres":
        return LocalPostgresDatabaseSource(**kwds)
    elif database_type == "postgres_docker":
        return DockerPostgresDatabaseSource(**kwds)
    # TODO
    # from .sqlite import SqliteDatabaseSource
    # elif database_type == "sqlite":
    #     return SqliteDatabaseSource(**kwds)
    else:
        raise Exception("Unknown database type [%s]." % database_type)
Exemplo n.º 6
0
 def test_build_mulled(self):
     if not which('docker'):
         raise unittest.SkipTest(
             "Docker not found on PATH, required for building images via involucro"
         )
     resolver_type = self.build_mulled_resolver
     tool_id = 'mulled_example_multi_1'
     endpoint = "tools/%s/dependencies" % tool_id
     data = {'id': tool_id, 'resolver_type': resolver_type}
     create_response = self._post(endpoint, data=data, admin=True)
     self._assert_status_code_is(create_response, 200)
     response = create_response.json()
     assert any([
         True for d in response
         if d['dependency_type'] == self.container_type
     ])
Exemplo n.º 7
0
def ensure_gh(ctx, **kwds):
    """Ensure ``hub`` is on the system ``PATH``.

    This method will ensure ``hub`` is installed if it isn't available.

    For more information on ``hub`` checkout ...
    """
    gh_path = which("gh")
    if not gh_path:
        planemo_gh_path = os.path.join(ctx.workspace, "gh")
        if not os.path.exists(planemo_gh_path):
            _try_download_gh(planemo_gh_path)

        if not os.path.exists(planemo_gh_path):
            raise Exception(FAILED_TO_DOWNLOAD_GH)

        gh_path = planemo_gh_path
    return gh_path
Exemplo n.º 8
0
def skip_unless_executable(executable):
    if which(executable):
        return lambda func: func
    return skip("PATH doesn't contain executable %s" % executable)
Exemplo n.º 9
0
def skip_if_container_type_unavailable(cls):
    if not which(cls.container_type):
        raise unittest.SkipTest("Executable '%s' not found on PATH" %
                                cls.container_type)
Exemplo n.º 10
0
def skip_unless_executable(executable):
    if which(executable):
        return _identity
    return pytest.mark.skip("PATH doesn't contain executable %s" % executable)
Exemplo n.º 11
0
 def enabled(self):
     return bool(which("xmllint"))
Exemplo n.º 12
0
 def setUpClass(cls):
     if not which(cls.container_type):
         raise unittest.SkipTest("Executable '%s' not found on PATH" %
                                 cls.container_type)
     super(DockerizedJobsIntegrationTestCase, cls).setUpClass()