提交 3a66bcbf 编写于 作者: H Harish

process.py: Add subprocess stdin.write() method

Add support to provide input with subprocess.Popen's stdin.write
method. Optionally flush the input buffer.
Signed-off-by: NHarish <harish@linux.vnet.ibm.com>
上级 da338600
...@@ -531,6 +531,7 @@ class SubProcess(object): ...@@ -531,6 +531,7 @@ class SubProcess(object):
else: else:
stderr = subprocess.PIPE stderr = subprocess.PIPE
self._popen = subprocess.Popen(cmd, self._popen = subprocess.Popen(cmd,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=stderr, stderr=stderr,
shell=self.shell, shell=self.shell,
...@@ -701,6 +702,16 @@ class SubProcess(object): ...@@ -701,6 +702,16 @@ class SubProcess(object):
self._fill_results(rc) self._fill_results(rc)
return rc return rc
def stdin_write(self, value, flush=False):
"""
Call the subprocess stdin.write() method for any input to subprocess
Optionally flush the input buffer
"""
self._init_subprocess()
self._popen.stdin.write(value)
if flush:
self._popen.stdin.flush()
def stop(self): def stop(self):
""" """
Stop background subprocess. Stop background subprocess.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册