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
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
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))
def test_size_returns_none_for_non_tty(): with tempfile.TemporaryFile() as t: expect(tty.size(t)).to.be.none
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)))
def test_size_returns_none_for_non_tty(): with tempfile.TemporaryFile() as t: expect(tty.size(t)).to(be_none)