本文整理匯總了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)