예제 #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",
    }
예제 #2
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")
        attempt_database_preseed(ctx, None, database_location, **kwds)
        database_connection = DATABASE_LOCATION_TEMPLATE % database_location

    return {
        "database_type": database_type,
        "database_connection": database_connection,
        "engine": "galaxy",
    }
예제 #3
0
def delete_profile(ctx, profile_name, **kwds):
    """Delete profile with the specified name."""
    profile_directory = _profile_directory(ctx, profile_name)
    profile_options = _read_profile_options(profile_directory)
    database_type = profile_options.get("database_type")
    if database_type != "sqlite":
        database_source = create_database_source(**kwds)
        database_identifier = _profile_to_database_identifier(profile_name)
        database_source.delete_database(database_identifier, )
    shutil.rmtree(profile_directory)
예제 #4
0
def cli(ctx, identifier, **kwds):
    """Delete a *development* database.

    Currently the only implementation is postgres which will be managed with
    ``psql``.

    Planemo ``database_`` commands make it very easy to create and destroy
    databases, therefore it should not be used for production data - and it
    should not even be connnected to a production database server. Planemo
    is intended for development purposes only.

    Planemo will assume that it can manage and access postgres databases
    without specifying a password. This can be accomplished by configuring
    postgres to not required a password for the planemo user or by specifying
    a password in a ``.pgpass`` file.

    Planemo can be configured to not require a password for the planemo user in
    the postgres configuration file ``pg_hba.conf`` (on Ubuntu/Debian linux
    distros this file is in /etc/postgresql/<postgres_version>/main/ directory).
    Adding the following lines to that file will allow planemo and Galaxy to
    access the databases without a password.

    \b
        # "local" is for Unix domain socket connections only
        local   all   all                    trust
        # IPv4 local connections:
        host    all   all    127.0.0.1/32    trust
        # IPv6 local connections:
        host    all   all    ::1/128         trust

    More information on the ``pg_hda.conf`` configuration file can be found at
    http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html.

    Information on ``.pgpass`` files can be found at at the following location:
    http://www.postgresql.org/docs/9.4/static/libpq-pgpass.html. In Ubuntu and
    Debian distros - a postgres user likely already exists and its password can
    be set by setting up a file ``~/.pgpass`` file with the following contents.

    \b
        *:*:*:postgres:<postgres_password>
    """
    create_database_source(**kwds).delete_database(identifier)
예제 #5
0
def cli(ctx, identifier, **kwds):
    """Delete a *development* database.

    Currently the only implementation is postgres which will be managed with
    ``psql``.

    Planemo ``database_`` commands make it very easy to create and destroy
    databases, therefore it should not be used for production data - and it
    should not even be connnected to a production database server. Planemo
    is intended for development purposes only.

    Planemo will assume that it can manage and access postgres databases
    without specifying a password. This can be accomplished by configuring
    postgres to not required a password for the planemo user or by specifying
    a password in a ``.pgpass`` file.

    Planemo can be configured to not require a password for the planemo user in
    the postgres configuration file ``pg_hba.conf`` (on Ubuntu/Debian linux
    distros this file is in /etc/postgresql/<postgres_version>/main/ directory).
    Adding the following lines to that file will allow planemo and Galaxy to
    access the databases without a password.::

        # "local" is for Unix domain socket connections only
        local   all   all                    trust
        # IPv4 local connections:
        host    all   all    127.0.0.1/32    trust
        # IPv6 local connections:
        host    all   all    ::1/128         trust

    More information on the ``pg_hda.conf`` configuration file can be found at
    http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html.

    Information on ``.pgpass`` files can be found at at the following location:
    http://www.postgresql.org/docs/9.4/static/libpq-pgpass.html. In Ubuntu and
    Debian distros - a postgres user likely already exists and its password can
    be set by setting up a file ``~/.pgpass`` file with the following contents.

    ::

        *:*:*:postgres:<postgres_password>
    """
    create_database_source(**kwds).delete_database(identifier)
예제 #6
0
def delete_profile(ctx, profile_name, **kwds):
    """Delete profile with the specified name."""
    profile_directory = _profile_directory(ctx, profile_name)
    profile_options = _read_profile_options(profile_directory)
    database_type = profile_options.get("database_type")
    if database_type != "sqlite":
        database_source = create_database_source(**kwds)
        database_identifier = _profile_to_database_identifier(profile_name)
        database_source.delete_database(
            database_identifier,
        )
    shutil.rmtree(profile_directory)
예제 #7
0
파일: profiles.py 프로젝트: nvk747/planemo
def delete_profile(ctx, profile_name, **kwds):
    """Delete profile with the specified name."""
    profile_directory = _profile_directory(ctx, profile_name)
    profile_options = _read_profile_options(profile_directory)
    profile_options, profile_options_path = _load_profile_to_json(
        ctx, profile_name)
    if profile_options["engine"] != 'external_galaxy':
        database_type = profile_options.get("database_type")
        kwds["database_type"] = database_type
        if database_type != "sqlite":
            database_source = create_database_source(**kwds)
            database_identifier = _profile_to_database_identifier(profile_name)
            database_source.delete_database(database_identifier, )
    shutil.rmtree(profile_directory)
예제 #8
0
def _create_profile_local(profile_directory, profile_name, kwds):
    database_type = kwds.get("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")
        attempt_database_preseed(None, database_location, **kwds)
        database_connection = DATABASE_LOCATION_TEMPLATE % database_location

    return {
        "database_type": database_type,
        "database_connection": database_connection,
        "engine": "galaxy",
    }