本文整理汇总了Python中pants.java.nailgun_protocol.NailgunProtocol.ttynames_from_env方法的典型用法代码示例。如果您正苦于以下问题:Python NailgunProtocol.ttynames_from_env方法的具体用法?Python NailgunProtocol.ttynames_from_env怎么用?Python NailgunProtocol.ttynames_from_env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.java.nailgun_protocol.NailgunProtocol
的用法示例。
在下文中一共展示了NailgunProtocol.ttynames_from_env方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _tty_stdio
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import ttynames_from_env [as 别名]
def _tty_stdio(self):
"""Handles stdio redirection in the case of all stdio descriptors being the same tty."""
# If all stdio is a tty, there's only one logical I/O device (the tty device). This happens to
# be addressable as a file in OSX and Linux, so we take advantage of that and directly open the
# character device for output redirection - eliminating the need to directly marshall any
# interactive stdio back/forth across the socket and permitting full, correct tty control with
# no middle-man.
stdin_ttyname, stdout_ttyname, stderr_ttyname = NailgunProtocol.ttynames_from_env(self._env)
assert stdin_ttyname == stdout_ttyname == stderr_ttyname, (
'expected all stdio ttys to be the same, but instead got: {}\n'
'please file a bug at http://github.com/pantsbuild/pants'
.format([stdin_ttyname, stdout_ttyname, stderr_ttyname])
)
with open(stdin_ttyname, 'rb+wb', 0) as tty:
tty_fileno = tty.fileno()
with stdio_as(stdin_fd=tty_fileno, stdout_fd=tty_fileno, stderr_fd=tty_fileno):
def finalizer():
termios.tcdrain(tty_fileno)
yield finalizer