本文整理汇总了Python中pants.java.nailgun_protocol.NailgunProtocol.isatty_from_env方法的典型用法代码示例。如果您正苦于以下问题:Python NailgunProtocol.isatty_from_env方法的具体用法?Python NailgunProtocol.isatty_from_env怎么用?Python NailgunProtocol.isatty_from_env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.java.nailgun_protocol.NailgunProtocol
的用法示例。
在下文中一共展示了NailgunProtocol.isatty_from_env方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_isatty_from_env_mixed
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_from_env [as 别名]
def test_isatty_from_env_mixed(self):
self.assertEquals(
NailgunProtocol.isatty_from_env({
'NAILGUN_TTY_0': '0',
'NAILGUN_TTY_1': '1'
}),
(False, True, False)
)
示例2: _nailgunned_stdio
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_from_env [as 别名]
def _nailgunned_stdio(self, sock):
"""Redirects stdio to the connected socket speaking the nailgun protocol."""
# Determine output tty capabilities from the environment.
stdin_isatty, stdout_isatty, stderr_isatty = NailgunProtocol.isatty_from_env(self._env)
if all((stdin_isatty, stdout_isatty, stderr_isatty)):
with self._tty_stdio() as finalizer:
yield finalizer
else:
with self._pipe_stdio(sock, stdin_isatty, stdout_isatty, stderr_isatty) as finalizer:
yield finalizer
示例3: _nailgunned_stdio
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_from_env [as 别名]
def _nailgunned_stdio(self, sock):
"""Redirects stdio to the connected socket speaking the nailgun protocol."""
# Determine output tty capabilities from the environment.
_, stdout_isatty, stderr_isatty = NailgunProtocol.isatty_from_env(self._env)
# TODO(kwlzn): Implement remote input reading and fix the non-fork()-safe sys.stdin reference
# in NailgunClient to enable support for interactive goals like `repl` etc.
# Construct StreamWriters for stdout, stderr.
streams = (
NailgunStreamWriter(sock, ChunkType.STDOUT, isatty=stdout_isatty),
NailgunStreamWriter(sock, ChunkType.STDERR, isatty=stderr_isatty)
)
# Launch the stdin StreamReader and redirect stdio.
with stdio_as(*streams):
yield
示例4: nailgunned_stdio
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_from_env [as 别名]
def nailgunned_stdio(cls, sock, env, handle_stdin=True):
"""Redirects stdio to the connected socket speaking the nailgun protocol."""
# Determine output tty capabilities from the environment.
stdin_isatty, stdout_isatty, stderr_isatty = NailgunProtocol.isatty_from_env(env)
is_tty_capable = all((stdin_isatty, stdout_isatty, stderr_isatty))
if is_tty_capable:
with cls._tty_stdio(env) as finalizer:
yield finalizer
else:
with cls._pipe_stdio(
sock,
stdin_isatty,
stdout_isatty,
stderr_isatty,
handle_stdin
) as finalizer:
yield finalizer
示例5: _nailgunned_stdio
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_from_env [as 别名]
def _nailgunned_stdio(self, sock):
"""Redirects stdio to the connected socket speaking the nailgun protocol."""
# Determine output tty capabilities from the environment.
_, stdout_isatty, stderr_isatty = NailgunProtocol.isatty_from_env(self._env)
# Construct a StreamReader for stdin.
stdin_reader = NailgunStreamReader(sys.stdin, sock)
# Construct StreamWriters for stdout, stderr.
streams = (
NailgunStreamWriter(sock, ChunkType.STDOUT, isatty=stdout_isatty),
NailgunStreamWriter(sock, ChunkType.STDERR, isatty=stderr_isatty),
stdin_reader
)
# Launch the stdin StreamReader and redirect stdio.
with stdin_reader.running(), stdio_as(*streams):
yield
示例6: test_isatty_from_empty_env
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_from_env [as 别名]
def test_isatty_from_empty_env(self):
self.assertEquals(NailgunProtocol.isatty_from_env({}), (False, False, False))