本文整理匯總了Python中sgi._getpty方法的典型用法代碼示例。如果您正苦於以下問題:Python sgi._getpty方法的具體用法?Python sgi._getpty怎麽用?Python sgi._getpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sgi
的用法示例。
在下文中一共展示了sgi._getpty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: master_open
# 需要導入模塊: import sgi [as 別名]
# 或者: from sgi import _getpty [as 別名]
def master_open():
try:
import sgi
except ImportError:
pass
else:
try:
tty_name, master_fd = sgi._getpty(fcntl.O_RDWR, 0o666, 0)
except IOError as msg:
raise os.error(msg)
return master_fd, tty_name
for x in 'pqrstuvwxyzPQRST':
for y in '0123456789abcdef':
pty_name = '/dev/pty' + x + y
try:
fd = os.open(pty_name, fcntl.O_RDWR)
except os.error:
continue
return (fd, '/dev/tty' + x + y)
raise os.error('out of pty devices')
# Open the pty slave. Acquire the controlling terminal.
# Returns file descriptor. Linux version. (Should be universal? --Guido)
# Copied from pty.py from Python 1.5.2. /SN
示例2: _open_terminal
# 需要導入模塊: import sgi [as 別名]
# 或者: from sgi import _getpty [as 別名]
def _open_terminal():
"""Open pty master and return (master_fd, tty_name).
SGI and generic BSD version, for when openpty() fails."""
try:
import sgi
except ImportError:
pass
else:
try:
tty_name, master_fd = sgi._getpty(os.O_RDWR, 0666, 0)
except IOError, msg:
raise os.error, msg
return master_fd, tty_name