Пример #1
0
def _docker_compose(*args):
    from compose.cli.main import main

    sys.argv = ["docker-compose", *args]
    main()
    # If we're still running, escape
    sys.exit(0)
Пример #2
0
def run_compose(
    args: List[str],
    variant: str = "services",
    dry_run: bool = False,
    project: Optional["derex.runner.project.Project"] = None,
    exit_afterwards: bool = False,
):
    """Run a docker-compose command passed in the `args` list.
    If `variant` is passed, load plugins for that variant.
    If a project is passed, load plugins for that project.
    """
    old_argv = sys.argv
    try:
        sys.argv = get_compose_options(args=args,
                                       variant=variant,
                                       project=project)
        if not dry_run:
            click.echo(f'Running\n{" ".join(sys.argv)}', err=True)
            if exit_afterwards:
                main()
            else:
                with exit_cm():
                    main()
        else:
            click.echo("Would have run:\n")
            click.echo(click.style(" ".join(sys.argv), fg="blue"))
    finally:
        sys.argv = old_argv
Пример #3
0
def run_compose(*cli_args):
    prev_argv = sys.argv
    try:
        sys.argv = ['docker-compose'] + list(cli_args)
        from compose.cli import main as docker_main
        docker_main.main()
    finally:
        sys.argv = prev_argv
Пример #4
0
    def run_command(self, command: str):
        argv = [
            sys.argv[0],
            '-p',
            self._config['name'],
            '-f',
            self._get_config_path(),
        ]

        sys.argv = argv
        if command is not None:
            sys.argv = argv + command.split(' ')

        main()
Пример #5
0
def runComposeCli(args, path='.', logger=None, collectOutput=False):
    cwd = os.getcwd()
    os.chdir(path)
    sys.argv = ['docker-compose'] + args
    if logger:
        logger.info('Running docker-compose command: {}'.format(' '.join(sys.argv)))

    stdout = sys.stdout
    stdoutFake = None
    sysexit = sys.exit

    if collectOutput:
        stdoutFake = io.StringIO("")
        sys.stdout = stdoutFake

    sys.exit = sysExitFake

    res = main()

    sys.stdout = stdout
    sys.exit = sysexit
    os.chdir(cwd)

    if collectOutput:
        res = stdoutFake.getvalue()

    return res
Пример #6
0
def run_docker_compose(compose_argv: List[str],
                       dry_run: bool = False,
                       exit_afterwards: bool = False):
    """Run a docker-compose command with the specified arguments.
    """
    system_argv = sys.argv
    try:
        sys.argv = ["docker-compose"] + compose_argv
        if not dry_run:
            click.echo(f'Running\n{" ".join(sys.argv)}', err=True)
            if exit_afterwards:
                main()
            else:
                with exit_cm():
                    main()
        else:
            click.echo("Would have run:\n")
            click.echo(click.style(" ".join(sys.argv), fg="blue"))
    finally:
        sys.argv = system_argv
Пример #7
0
def run_compose(
    args: List[str],
    variant: str = "services",
    dry_run: bool = False,
    project: Optional["derex.runner.project.Project"] = None,
):
    """Run a docker-compose command passed in the `args` list.
    If `variant` is passed, load plugins for that variant.
    If a project is passed, load plugins for that project.
    """
    plugin_manager = setup_plugin_manager()
    registry = Registry()
    if project:
        for opts in plugin_manager.hook.local_compose_options(project=project):
            registry.add(key=opts["name"],
                         value=opts["options"],
                         location=opts["priority"])
    else:
        ensure_volumes_present()
        for opts in plugin_manager.hook.compose_options():
            if opts["variant"] == variant:
                registry.add(key=opts["name"],
                             value=opts["options"],
                             location=opts["priority"])
    settings = [el for lst in registry for el in lst]
    old_argv = sys.argv
    try:
        sys.argv = ["docker-compose"] + settings + args
        if not dry_run:
            click.echo(f'Running {" ".join(sys.argv)}', err=True)
            main()
        else:
            click.echo("Would have run:")
            click.echo(click.style(" ".join(sys.argv), fg="blue"))
    finally:
        sys.argv = old_argv
Пример #8
0
from __future__ import absolute_import
from __future__ import unicode_literals

from compose.cli.main import main

main()
Пример #9
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

from compose.cli import main


import googlecluo



main.main()