Esempio n. 1
0
    def resize(self, size=None):
        """
        Resize the container's PTY.

        If `size` is not None, it must be a tuple of (height,width), otherwise
        it will be determined by the size of the current TTY.
        """

        if not self.israw():
            return

        size = size or tty.size(sys.stdout)

        if size is not None:
            rows, cols = size
            try:
                self.client.resize(self.container, height=rows, width=cols)
            except IOError: # Container already exited
                pass
Esempio n. 2
0
    def resize(self, size=None):
        """
        Resize the container's PTY.

        If `size` is not None, it must be a tuple of (height,width), otherwise
        it will be determined by the size of the current TTY.
        """

        if not self.israw():
            return

        size = size or tty.size(self.stdout)

        if size is not None:
            rows, cols = size
            try:
                self.client.resize(self.container, height=rows, width=cols)
            except IOError:  # Container already exited
                pass
Esempio n. 3
0
def test_size_returns_a_tuple_for_a_tty():
    fd, __ = pty.openpty()
    fd = os.fdopen(fd)
    util.set_pty_size(fd, (43, 120))
    expect(tty.size(fd)).to.equal((43, 120))
Esempio n. 4
0
def test_size_returns_none_for_non_tty():
    with tempfile.TemporaryFile() as t:
        expect(tty.size(t)).to.be.none
Esempio n. 5
0
def test_size_returns_a_tuple_for_a_tty():
    fd, __ = pty.openpty()
    fd = os.fdopen(fd)
    util.set_pty_size(fd, (43, 120))
    expect(tty.size(fd)).to(equal((43, 120)))
Esempio n. 6
0
def test_size_returns_none_for_non_tty():
    with tempfile.TemporaryFile() as t:
        expect(tty.size(t)).to(be_none)