本文整理汇总了Python中pants.java.nailgun_protocol.NailgunProtocol.isatty_to_env方法的典型用法代码示例。如果您正苦于以下问题:Python NailgunProtocol.isatty_to_env方法的具体用法?Python NailgunProtocol.isatty_to_env怎么用?Python NailgunProtocol.isatty_to_env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.java.nailgun_protocol.NailgunProtocol
的用法示例。
在下文中一共展示了NailgunProtocol.isatty_to_env方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_isatty_to_env_without_tty
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_to_env [as 别名]
def test_isatty_to_env_without_tty(self):
mock_stdin = self._make_mock_stream(False, 0)
mock_stdout = self._make_mock_stream(False, 1)
mock_stderr = self._make_mock_stream(False, 2)
self.assertEqual(
NailgunProtocol.isatty_to_env(mock_stdin, mock_stdout, mock_stderr),
{
'NAILGUN_TTY_0': b'0',
'NAILGUN_TTY_1': b'0',
'NAILGUN_TTY_2': b'0',
})
示例2: run
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_to_env [as 别名]
def run(self, args=None):
# Merge the nailgun TTY capability environment variables with the passed environment dict.
ng_env = NailgunProtocol.isatty_to_env(self._stdin, self._stdout, self._stderr)
modified_env = self._combine_dicts(self._env, ng_env)
# Instantiate a NailgunClient.
client = NailgunClient(port=self._port, ins=self._stdin, out=self._stdout, err=self._stderr)
with self._trapped_control_c(client):
# Execute the command on the pailgun.
result = client.execute(self.PANTS_COMMAND, *self._args, **modified_env)
# Exit.
self._exiter.exit(result)
示例3: test_isatty_to_env_with_mock_tty
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_to_env [as 别名]
def test_isatty_to_env_with_mock_tty(self, mock_ttyname):
mock_ttyname.return_value = self._fake_ttyname
mock_stdin = self._make_mock_stream(True, 0)
mock_stdout = self._make_mock_stream(True, 1)
mock_stderr = self._make_mock_stream(True, 2)
self.assertEqual(
NailgunProtocol.isatty_to_env(mock_stdin, mock_stdout, mock_stderr),
{
'NAILGUN_TTY_0': b'1',
'NAILGUN_TTY_1': b'1',
'NAILGUN_TTY_2': b'1',
'NAILGUN_TTY_PATH_0': self._fake_ttyname,
'NAILGUN_TTY_PATH_1': self._fake_ttyname,
'NAILGUN_TTY_PATH_2': self._fake_ttyname,
})
示例4: _connect_and_execute
# 需要导入模块: from pants.java.nailgun_protocol import NailgunProtocol [as 别名]
# 或者: from pants.java.nailgun_protocol.NailgunProtocol import isatty_to_env [as 别名]
def _connect_and_execute(self, port):
# Merge the nailgun TTY capability environment variables with the passed environment dict.
ng_env = NailgunProtocol.isatty_to_env(self._stdin, self._stdout, self._stderr)
modified_env = combined_dict(self._env, ng_env)
assert isinstance(port, int), 'port {} is not an integer!'.format(port)
# Instantiate a NailgunClient.
client = NailgunClient(port=port,
ins=self._stdin,
out=self._stdout,
err=self._stderr,
exit_on_broken_pipe=True)
with self._trapped_signals(client), STTYSettings.preserved():
# Execute the command on the pailgun.
result = client.execute(self.PANTS_COMMAND, *self._args, **modified_env)
# Exit.
self._exiter.exit(result)