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)
downloadpoky-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):
64 options.update(kwargs) 64 options.update(kwargs)
65 subprocess.Popen.__init__(self, *args, **options) 65 subprocess.Popen.__init__(self, *args, **options)
66 66
67def _logged_communicate(pipe, log, input): 67def _logged_communicate(pipe, log, input, extrafiles):
68 if pipe.stdin: 68 if pipe.stdin:
69 if input is not None: 69 if input is not None:
70 pipe.stdin.write(input) 70 pipe.stdin.write(input)
@@ -79,6 +79,19 @@ def _logged_communicate(pipe, log, input):
79 if pipe.stderr is not None: 79 if pipe.stderr is not None:
80 bb.utils.nonblockingfd(pipe.stderr.fileno()) 80 bb.utils.nonblockingfd(pipe.stderr.fileno())
81 rin.append(pipe.stderr) 81 rin.append(pipe.stderr)
82 for fobj, _ in extrafiles:
83 bb.utils.nonblockingfd(fobj.fileno())
84 rin.append(fobj)
85
86 def readextras():
87 for fobj, func in extrafiles:
88 try:
89 data = fobj.read()
90 except IOError as err:
91 if err.errno == errno.EAGAIN or err.errno == errno.EWOULDBLOCK:
92 data = None
93 if data is not None:
94 func(data)
82 95
83 try: 96 try:
84 while pipe.poll() is None: 97 while pipe.poll() is None:
@@ -100,15 +113,21 @@ def _logged_communicate(pipe, log, input):
100 if data is not None: 113 if data is not None:
101 errdata.append(data) 114 errdata.append(data)
102 log.write(data) 115 log.write(data)
116
117 readextras()
118
103 finally: 119 finally:
104 log.flush() 120 log.flush()
121
122 readextras()
123
105 if pipe.stdout is not None: 124 if pipe.stdout is not None:
106 pipe.stdout.close() 125 pipe.stdout.close()
107 if pipe.stderr is not None: 126 if pipe.stderr is not None:
108 pipe.stderr.close() 127 pipe.stderr.close()
109 return ''.join(outdata), ''.join(errdata) 128 return ''.join(outdata), ''.join(errdata)
110 129
111def run(cmd, input=None, log=None, **options): 130def run(cmd, input=None, log=None, extrafiles=[], **options):
112 """Convenience function to run a command and return its output, raising an 131 """Convenience function to run a command and return its output, raising an
113 exception when the command fails""" 132 exception when the command fails"""
114 133
@@ -124,7 +143,7 @@ def run(cmd, input=None, log=None, **options):
124 raise CmdError(cmd, exc) 143 raise CmdError(cmd, exc)
125 144
126 if log: 145 if log:
127 stdout, stderr = _logged_communicate(pipe, log, input) 146 stdout, stderr = _logged_communicate(pipe, log, input, extrafiles)
128 else: 147 else:
129 stdout, stderr = pipe.communicate(input) 148 stdout, stderr = pipe.communicate(input)
130 149