Python tty.TIOCSWINSZ Examples
The following are 9
code examples of tty.TIOCSWINSZ().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tty
, or try the search function
.
Example #1
Source File: unix.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def openShell(self, proto): if not self.ptyTuple: # We didn't get a pty-req. log.msg('tried to get shell without pty, failing') raise ConchError("no pty") uid, gid = self.avatar.getUserGroupId() homeDir = self.avatar.getHomeDir() shell = self.avatar.getShell() self.environ['USER'] = self.avatar.username self.environ['HOME'] = homeDir self.environ['SHELL'] = shell shellExec = os.path.basename(shell) peer = self.avatar.conn.transport.transport.getPeer() host = self.avatar.conn.transport.transport.getHost() self.environ['SSH_CLIENT'] = '%s %s %s' % ( peer.host, peer.port, host.port) self.getPtyOwnership() self.pty = self._reactor.spawnProcess( proto, shell, ['-%s' % (shellExec,)], self.environ, homeDir, uid, gid, usePTY=self.ptyTuple) self.addUTMPEntry() fcntl.ioctl(self.pty.fileno(), tty.TIOCSWINSZ, struct.pack('4H', *self.winSize)) if self.modes: self.setModes() self.oldWrite = proto.transport.write proto.transport.write = self._writeHack self.avatar.conn.transport.transport.setTcpNoDelay(1)
Example #2
Source File: unix.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 5 votes |
def windowChanged(self, winSize): self.winSize = winSize fcntl.ioctl( self.pty.fileno(), tty.TIOCSWINSZ, struct.pack('4H', *self.winSize))
Example #3
Source File: unix.py From learn_python3_spider with MIT License | 5 votes |
def openShell(self, proto): if not self.ptyTuple: # We didn't get a pty-req. log.msg('tried to get shell without pty, failing') raise ConchError("no pty") uid, gid = self.avatar.getUserGroupId() homeDir = self.avatar.getHomeDir() shell = self.avatar.getShell() self.environ['USER'] = self.avatar.username self.environ['HOME'] = homeDir self.environ['SHELL'] = shell shellExec = os.path.basename(shell) peer = self.avatar.conn.transport.transport.getPeer() host = self.avatar.conn.transport.transport.getHost() self.environ['SSH_CLIENT'] = '%s %s %s' % ( peer.host, peer.port, host.port) self.getPtyOwnership() self.pty = self._reactor.spawnProcess( proto, shell, ['-%s' % (shellExec,)], self.environ, homeDir, uid, gid, usePTY=self.ptyTuple) self.addUTMPEntry() fcntl.ioctl(self.pty.fileno(), tty.TIOCSWINSZ, struct.pack('4H', *self.winSize)) if self.modes: self.setModes() self.oldWrite = proto.transport.write proto.transport.write = self._writeHack self.avatar.conn.transport.transport.setTcpNoDelay(1)
Example #4
Source File: unix.py From learn_python3_spider with MIT License | 5 votes |
def windowChanged(self, winSize): self.winSize = winSize fcntl.ioctl( self.pty.fileno(), tty.TIOCSWINSZ, struct.pack('4H', *self.winSize))
Example #5
Source File: unix.py From python-for-android with Apache License 2.0 | 5 votes |
def openShell(self, proto): from twisted.internet import reactor if not self.ptyTuple: # we didn't get a pty-req log.msg('tried to get shell without pty, failing') raise ConchError("no pty") uid, gid = self.avatar.getUserGroupId() homeDir = self.avatar.getHomeDir() shell = self.avatar.getShell() self.environ['USER'] = self.avatar.username self.environ['HOME'] = homeDir self.environ['SHELL'] = shell shellExec = os.path.basename(shell) peer = self.avatar.conn.transport.transport.getPeer() host = self.avatar.conn.transport.transport.getHost() self.environ['SSH_CLIENT'] = '%s %s %s' % (peer.host, peer.port, host.port) self.getPtyOwnership() self.pty = reactor.spawnProcess(proto, \ shell, ['-%s' % shellExec], self.environ, homeDir, uid, gid, usePTY = self.ptyTuple) self.addUTMPEntry() fcntl.ioctl(self.pty.fileno(), tty.TIOCSWINSZ, struct.pack('4H', *self.winSize)) if self.modes: self.setModes() self.oldWrite = proto.transport.write proto.transport.write = self._writeHack self.avatar.conn.transport.transport.setTcpNoDelay(1)
Example #6
Source File: unix.py From python-for-android with Apache License 2.0 | 5 votes |
def windowChanged(self, winSize): self.winSize = winSize fcntl.ioctl(self.pty.fileno(), tty.TIOCSWINSZ, struct.pack('4H', *self.winSize))
Example #7
Source File: unix.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def openShell(self, proto): from twisted.internet import reactor if not self.ptyTuple: # we didn't get a pty-req log.msg('tried to get shell without pty, failing') raise ConchError("no pty") uid, gid = self.avatar.getUserGroupId() homeDir = self.avatar.getHomeDir() shell = self.avatar.getShell() self.environ['USER'] = self.avatar.username self.environ['HOME'] = homeDir self.environ['SHELL'] = shell shellExec = os.path.basename(shell) peer = self.avatar.conn.transport.transport.getPeer() host = self.avatar.conn.transport.transport.getHost() self.environ['SSH_CLIENT'] = '%s %s %s' % (peer.host, peer.port, host.port) self.getPtyOwnership() self.pty = reactor.spawnProcess(proto, \ shell, ['-%s' % shellExec], self.environ, homeDir, uid, gid, usePTY = self.ptyTuple) self.addUTMPEntry() fcntl.ioctl(self.pty.fileno(), tty.TIOCSWINSZ, struct.pack('4H', *self.winSize)) if self.modes: self.setModes() self.oldWrite = proto.transport.write proto.transport.write = self._writeHack self.avatar.conn.transport.transport.setTcpNoDelay(1)
Example #8
Source File: unix.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def windowChanged(self, winSize): self.winSize = winSize fcntl.ioctl(self.pty.fileno(), tty.TIOCSWINSZ, struct.pack('4H', *self.winSize))
Example #9
Source File: test_runner.py From imaginary with MIT License | 5 votes |
def setTerminalSize(terminalFD, ws_row=25, ws_col=80, ws_xpixel=0, ws_ypixel=0): """ Set the size of the given PTY leader file descriptor. """ structformat = '4H' data = struct.pack(structformat, ws_row, ws_col, ws_xpixel, ws_ypixel) fcntl.ioctl(terminalFD, tty.TIOCSWINSZ, data)