process: fix handling of the input argument
When using a logfile, we weren't sending input to the child process. (Bitbake rev: 5ec4ca7e45bdf6d259503fc67155395e89ba6329) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
parent
572bf4b382
commit
043adbfa09
|
@ -63,23 +63,26 @@ class Popen(subprocess.Popen):
|
||||||
subprocess.Popen.__init__(self, *args, **options)
|
subprocess.Popen.__init__(self, *args, **options)
|
||||||
|
|
||||||
def _logged_communicate(pipe, log, input):
|
def _logged_communicate(pipe, log, input):
|
||||||
bufsize = 512
|
if pipe.stdin:
|
||||||
hasoutput = pipe.stdout is not None or pipe.stderr is not None
|
if input is not None:
|
||||||
if hasoutput:
|
pipe.stdin.write(input)
|
||||||
outdata, errdata = [], []
|
pipe.stdin.close()
|
||||||
while pipe.poll() is None:
|
|
||||||
if pipe.stdout is not None:
|
|
||||||
data = pipe.stdout.read(bufsize)
|
|
||||||
if data is not None:
|
|
||||||
outdata.append(data)
|
|
||||||
log.write(data)
|
|
||||||
|
|
||||||
if pipe.stderr is not None:
|
bufsize = 512
|
||||||
data = pipe.stderr.read(bufsize)
|
outdata, errdata = [], []
|
||||||
if data is not None:
|
while pipe.poll() is None:
|
||||||
errdata.append(data)
|
if pipe.stdout is not None:
|
||||||
log.write(data)
|
data = pipe.stdout.read(bufsize)
|
||||||
return ''.join(outdata), ''.join(errdata)
|
if data is not None:
|
||||||
|
outdata.append(data)
|
||||||
|
log.write(data)
|
||||||
|
|
||||||
|
if pipe.stderr is not None:
|
||||||
|
data = pipe.stderr.read(bufsize)
|
||||||
|
if data is not None:
|
||||||
|
errdata.append(data)
|
||||||
|
log.write(data)
|
||||||
|
return ''.join(outdata), ''.join(errdata)
|
||||||
|
|
||||||
def run(cmd, input=None, **options):
|
def run(cmd, input=None, **options):
|
||||||
"""Convenience function to run a command and return its output, raising an
|
"""Convenience function to run a command and return its output, raising an
|
||||||
|
|
Loading…
Reference in New Issue