Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
minrows = mincols = 10001
if rows is not None and rows < minrows:
minrows = rows
if cols is not None and cols < mincols:
mincols = cols
if minrows == 10001 or mincols == 10001:
return
rows, cols = self.ptyproc.getwinsize()
if (rows, cols) != (minrows, mincols):
self.ptyproc.setwinsize(minrows, mincols)
class TermManager(TermManagerBase):
"""Wrapper around pexpect to execute local commands."""
def __init__(self, shell_command, **kwargs):
"""Create a new terminal handler instance."""
super().__init__(shell_command, **kwargs)
self.consoles = {}
def new_terminal(self, **options):
"""Make a new terminal, return a :class:`PtyReader` instance."""
tty = super().new_terminal(**options)
return PtyReader(tty.ptyproc)
@tornado.gen.coroutine
def client_disconnected(self, pid, socket):
"""Send terminal SIGHUP when client disconnects."""
self.log.info("Websocket closed, sending SIGHUP to terminal.")