summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/knotty.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-08-31 11:30:44 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-08-31 23:30:03 +0100
commita3971620dc00d459dbc0ce25082feb7099fb967f (patch)
treec6b686c1fdbd2c0723431c3cf6794c6aeddc18c5 /bitbake/lib/bb/ui/knotty.py
parent6ef0a567706be050c65efcebf444510c0969ce89 (diff)
downloadpoky-a3971620dc00d459dbc0ce25082feb7099fb967f.tar.gz
bitbake: tinfoil: ensure log lines get printed when tasks fail
If a task fails during build_targets(), we need to print out the log lines as knotty does or the user will be missing information about the failure. (This should get some deeper refactoring, but now isn't the time for that.) (Bitbake rev: 24879df071d4803db3d39ae1d5cad852daa92f28) 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/ui/knotty.py')
-rw-r--r--bitbake/lib/bb/ui/knotty.py50
1 files changed, 27 insertions, 23 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 6b0781d8f0..fa88e6ccdd 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -312,6 +312,32 @@ class TerminalFilter(object):
312 fd = sys.stdin.fileno() 312 fd = sys.stdin.fileno()
313 self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup) 313 self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup)
314 314
315def print_event_log(event, includelogs, loglines, termfilter):
316 # FIXME refactor this out further
317 logfile = event.logfile
318 if logfile and os.path.exists(logfile):
319 termfilter.clearFooter()
320 bb.error("Logfile of failure stored in: %s" % logfile)
321 if includelogs and not event.errprinted:
322 print("Log data follows:")
323 f = open(logfile, "r")
324 lines = []
325 while True:
326 l = f.readline()
327 if l == '':
328 break
329 l = l.rstrip()
330 if loglines:
331 lines.append(' | %s' % l)
332 if len(lines) > int(loglines):
333 lines.pop(0)
334 else:
335 print('| %s' % l)
336 f.close()
337 if lines:
338 for line in lines:
339 print(line)
340
315def _log_settings_from_server(server, observe_only): 341def _log_settings_from_server(server, observe_only):
316 # Get values of variables which control our output 342 # Get values of variables which control our output
317 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"]) 343 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"])
@@ -489,29 +515,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
489 continue 515 continue
490 if isinstance(event, bb.build.TaskFailed): 516 if isinstance(event, bb.build.TaskFailed):
491 return_value = 1 517 return_value = 1
492 logfile = event.logfile 518 print_event_log(event, includelogs, loglines, termfilter)
493 if logfile and os.path.exists(logfile):
494 termfilter.clearFooter()
495 bb.error("Logfile of failure stored in: %s" % logfile)
496 if includelogs and not event.errprinted:
497 print("Log data follows:")
498 f = open(logfile, "r")
499 lines = []
500 while True:
501 l = f.readline()
502 if l == '':
503 break
504 l = l.rstrip()
505 if loglines:
506 lines.append(' | %s' % l)
507 if len(lines) > int(loglines):
508 lines.pop(0)
509 else:
510 print('| %s' % l)
511 f.close()
512 if lines:
513 for line in lines:
514 print(line)
515 if isinstance(event, bb.build.TaskBase): 519 if isinstance(event, bb.build.TaskBase):
516 logger.info(event._message) 520 logger.info(event._message)
517 continue 521 continue