示例#1
0
    def console(self, container: str, user: str, tty: bool):
        """Enter a container (stakkr allows only apache / php and mysql)"""

        docker_actions.check_cts_are_running(self.project_name)

        tty = 't' if tty is True else ''
        ct_name = docker_actions.get_ct_name(container)
        cmd = ['docker', 'exec', '-u', user, '-i' + tty]
        cmd += [docker_actions.get_ct_name(container), docker_actions.guess_shell(ct_name)]
        subprocess.call(cmd)

        command.verbose(self.context['VERBOSE'], 'Command : "' + ' '.join(cmd) + '"')
示例#2
0
    def console(self, container: str, user: str, tty: bool):
        """Enter a container. Stakkr will try to guess the right shell."""
        docker.check_cts_are_running(self.project_name)

        tty = 't' if tty is True else ''
        ct_name = docker.get_ct_name(container)
        cmd = ['docker', 'exec', '-u', user, '-i' + tty]
        cmd += [docker.get_ct_name(container), docker.guess_shell(ct_name)]
        subprocess.call(cmd)

        command.verbose(self.context['VERBOSE'],
                        'Command : "' + ' '.join(cmd) + '"')
示例#3
0
    def console(self, container: str, user: str, tty: bool):
        """Enter a container. Stakkr will try to guess the right shell."""
        self.init_project()

        docker.check_cts_are_running(self.project_name)

        tty = 't' if tty is True else ''
        ct_name = docker.get_ct_name(container)
        cmd = ['docker', 'exec', '-u', user, '-i' + tty]
        cmd += [docker.get_ct_name(container), docker.guess_shell(ct_name)]
        subprocess.call(cmd)

        command.verbose(self.context['VERBOSE'], 'Command : "' + ' '.join(cmd) + '"')
示例#4
0
def get_url(service_url: str, service: str, dns_started: bool):
    """Build URL to be displayed"""

    service_name = docker_actions.get_ct_name(service)
    service_ip = docker_actions.get_ct_item(service, 'ip')

    return service_url.format(service_name if dns_started else service_ip)
示例#5
0
    def console(self, container: str, user: str, tty: bool):
        """Enter a container (stakkr allows only apache / php and mysql)"""

        docker_actions.check_cts_are_running(self.project_name)

        tty = 't' if tty is True else ''
        ct_name = docker_actions.get_ct_name(container)
        cmd = ['docker', 'exec', '-u', user, '-i' + tty]
        cmd += [
            docker_actions.get_ct_name(container),
            docker_actions.guess_shell(ct_name)
        ]
        subprocess.call(cmd)

        command.verbose(self.context['VERBOSE'],
                        'Command : "' + ' '.join(cmd) + '"')
示例#6
0
def get_url(service_url: str, service: str, dns_started: bool):
    """Build URL to be displayed"""

    service_name = docker_actions.get_ct_name(service)
    service_ip = docker_actions.get_ct_item(service, 'ip')

    return service_url.format(service_name if dns_started else service_ip)
示例#7
0
    def exec_cmd(self, container: str, user: str, args: tuple, tty: bool):
        """Run a command from outside to any container. Wrapped into /bin/sh"""

        docker_actions.check_cts_are_running(self.project_name)

        # Protect args to avoid strange behavior in exec
        args = ['"{}"'.format(arg) for arg in args]

        tty = 't' if tty is True else ''
        ct_name = docker_actions.get_ct_name(container)
        cmd = ['docker', 'exec', '-u', user, '-i' + tty, ct_name, 'sh', '-c']
        cmd += ["""test -d "/var/{0}" && cd "/var/{0}" ; exec {1}""".format(self.cwd_relative, ' '.join(args))]
        command.verbose(self.context['VERBOSE'], 'Command : "' + ' '.join(cmd) + '"')
        subprocess.call(cmd, stdin=sys.stdin)
示例#8
0
文件: actions.py 项目: dwade75/stakkr
    def exec_cmd(self, container: str, user: str, args: tuple, tty: bool):
        """Run a command from outside to any container. Wrapped into /bin/sh"""

        docker_actions.check_cts_are_running(self.project_name)

        # Protect args to avoid strange behavior in exec
        args = ['"{}"'.format(arg) for arg in args]

        tty = 't' if tty is True else ''
        ct_name = docker_actions.get_ct_name(container)
        cmd = ['docker', 'exec', '-u', user, '-i' + tty, ct_name, 'sh', '-c']
        cmd += ["""test -d "/var/{0}" && cd "/var/{0}" ; exec {1}""".format(self.cwd_relative, ' '.join(args))]
        command.verbose(self.context['VERBOSE'], 'Command : "' + ' '.join(cmd) + '"')
        subprocess.call(cmd, stdin=sys.stdin)
示例#9
0
    def exec_cmd(self, container: str, user: str, args: tuple, tty: bool,
                 workdir: str):
        """Run a command from outside to any container. Wrapped into /bin/sh."""
        self.init_project()

        docker.check_cts_are_running(self.project_name)

        # Protect args to avoid strange behavior in exec
        args = ['"{}"'.format(arg) for arg in args]
        workdir = "/var/{}".format(
            self.cwd_relative) if workdir is None else workdir
        tty = 't' if tty is True else ''
        ct_name = docker.get_ct_name(container)
        cmd = [
            'docker', 'exec', '-u', user, '-i' + tty, '-w', workdir, ct_name,
            'sh', '-c'
        ]
        cmd += ["""exec {}""".format(' '.join(args))]
        command.verbose(self.context['VERBOSE'],
                        'Command : "' + ' '.join(cmd) + '"')
        subprocess.call(cmd, stdin=sys.stdin)