本文整理汇总了Python中tty.TIOCSWINSZ属性的典型用法代码示例。如果您正苦于以下问题:Python tty.TIOCSWINSZ属性的具体用法?Python tty.TIOCSWINSZ怎么用?Python tty.TIOCSWINSZ使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类tty
的用法示例。
在下文中一共展示了tty.TIOCSWINSZ属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: openShell
# 需要导入模块: import tty [as 别名]
# 或者: from tty import TIOCSWINSZ [as 别名]
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)
示例2: windowChanged
# 需要导入模块: import tty [as 别名]
# 或者: from tty import TIOCSWINSZ [as 别名]
def windowChanged(self, winSize):
self.winSize = winSize
fcntl.ioctl(
self.pty.fileno(), tty.TIOCSWINSZ,
struct.pack('4H', *self.winSize))
示例3: openShell
# 需要导入模块: import tty [as 别名]
# 或者: from tty import TIOCSWINSZ [as 别名]
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)
示例4: windowChanged
# 需要导入模块: import tty [as 别名]
# 或者: from tty import TIOCSWINSZ [as 别名]
def windowChanged(self, winSize):
self.winSize = winSize
fcntl.ioctl(self.pty.fileno(), tty.TIOCSWINSZ,
struct.pack('4H', *self.winSize))
示例5: setTerminalSize
# 需要导入模块: import tty [as 别名]
# 或者: from tty import TIOCSWINSZ [as 别名]
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)