summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/process.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-07-10 14:51:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-07-12 22:50:40 +0100
commit3b5031230717d7430951dfa4a148b7f83bad514b (patch)
tree8e5a487c2498ed49e1a28d7acc94e964e7d7a3ba /bitbake/lib/bb/process.py
parent8f8d3362b8631aa6d09f1ef9df5111ba7ce10f85 (diff)
downloadopenembedded-core-contrib-3b5031230717d7430951dfa4a148b7f83bad514b.tar.gz
bitbake: lib/bb: set up infrastructure for shell message functions
Create a fifo under ${T} for each running task that can be used by the task to send events back to BitBake. The purpose of this is to allow OpenEmbedded's logging.bbclass (which provides shell function equivalents for bb.warn(), bb.note() etc.) to have those functions trigger the appropriate events within BitBake so that messages are shown through the BitBake UI rather than just in the task log; to do that we just call the python functions. Part of the fix for [YOCTO #5275]. (Bitbake rev: bae330a1f8a59a912eca71177b3c6ba7c92a2f38) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/process.py')
-rw-r--r--bitbake/lib/bb/process.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/bitbake/lib/bb/process.py b/bitbake/lib/bb/process.py
index 8b1aea9a10..d95a03d176 100644
--- a/bitbake/lib/bb/process.py
+++ b/bitbake/lib/bb/process.py
@@ -64,7 +64,7 @@ class Popen(subprocess.Popen):
options.update(kwargs)
subprocess.Popen.__init__(self, *args, **options)
-def _logged_communicate(pipe, log, input):
+def _logged_communicate(pipe, log, input, extrafiles):
if pipe.stdin:
if input is not None:
pipe.stdin.write(input)
@@ -79,6 +79,19 @@ def _logged_communicate(pipe, log, input):
if pipe.stderr is not None:
bb.utils.nonblockingfd(pipe.stderr.fileno())
rin.append(pipe.stderr)
+ for fobj, _ in extrafiles:
+ bb.utils.nonblockingfd(fobj.fileno())
+ rin.append(fobj)
+
+ def readextras():
+ for fobj, func in extrafiles:
+ try:
+ data = fobj.read()
+ except IOError as err:
+ if err.errno == errno.EAGAIN or err.errno == errno.EWOULDBLOCK:
+ data = None
+ if data is not None:
+ func(data)
try:
while pipe.poll() is None:
@@ -100,15 +113,21 @@ def _logged_communicate(pipe, log, input):
if data is not None:
errdata.append(data)
log.write(data)
+
+ readextras()
+
finally:
log.flush()
+
+ readextras()
+
if pipe.stdout is not None:
pipe.stdout.close()
if pipe.stderr is not None:
pipe.stderr.close()
return ''.join(outdata), ''.join(errdata)
-def run(cmd, input=None, log=None, **options):
+def run(cmd, input=None, log=None, extrafiles=[], **options):
"""Convenience function to run a command and return its output, raising an
exception when the command fails"""
@@ -124,7 +143,7 @@ def run(cmd, input=None, log=None, **options):
raise CmdError(cmd, exc)
if log:
- stdout, stderr = _logged_communicate(pipe, log, input)
+ stdout, stderr = _logged_communicate(pipe, log, input, extrafiles)
else:
stdout, stderr = pipe.communicate(input)