diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2020-03-12 13:30:03 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-03-13 11:29:23 +0000 |
commit | 5ce50b3ce7ba91b9e34a9ce8f17b4ff43a8c73e6 (patch) | |
tree | e6708a6ebc80b0275611b5a968084a640d988736 /bitbake/lib | |
parent | 0dd9e5a84d83cd3b1f623cae52fea10f5eb59f9b (diff) | |
download | poky-5ce50b3ce7ba91b9e34a9ce8f17b4ff43a8c73e6.tar.gz |
bitbake: knotty: Treat verbconsole as a console output
The BitBake.verbconsole needs to be treated like a console output logger
(meaning that the TerminalFilter attaches an InteractConsoleLogFilter to
it), even if it's not directly attached to the root 'BitBake' logger.
First, assign a special "is_console" property to the relevant handlers,
then look for the property in the handlers from the configuration object
return by bb.msg.setLoggingConfig(). Finally, pass the list of all
handlers to the TerminalFilter object; it doesn't care about the
difference between console and errconsole, so pass all the relevant
handlers as a list.
This fixes cases where the console output was corrupted when messages
were sent to the 'BitBake.verbconsole' handler.
(Bitbake rev: 2010be588c74a99256df7b565a309c84c2973546)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/ui/knotty.py | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 24b7a77085..826aa8c3e7 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py | |||
@@ -149,7 +149,7 @@ class TerminalFilter(object): | |||
149 | cr = (25, 80) | 149 | cr = (25, 80) |
150 | return cr | 150 | return cr |
151 | 151 | ||
152 | def __init__(self, main, helper, console, errconsole, quiet): | 152 | def __init__(self, main, helper, handlers, quiet): |
153 | self.main = main | 153 | self.main = main |
154 | self.helper = helper | 154 | self.helper = helper |
155 | self.cuu = None | 155 | self.cuu = None |
@@ -179,14 +179,9 @@ class TerminalFilter(object): | |||
179 | termios.tcsetattr(fd, termios.TCSADRAIN, new) | 179 | termios.tcsetattr(fd, termios.TCSADRAIN, new) |
180 | curses.setupterm() | 180 | curses.setupterm() |
181 | if curses.tigetnum("colors") > 2: | 181 | if curses.tigetnum("colors") > 2: |
182 | if console: | 182 | for h in handlers: |
183 | try: | 183 | try: |
184 | console.formatter.enable_color() | 184 | h.formatter.enable_color() |
185 | except AttributeError: | ||
186 | pass | ||
187 | if errconsole: | ||
188 | try: | ||
189 | errconsole.formatter.enable_color() | ||
190 | except AttributeError: | 185 | except AttributeError: |
191 | pass | 186 | pass |
192 | self.ed = curses.tigetstr("ed") | 187 | self.ed = curses.tigetstr("ed") |
@@ -204,10 +199,9 @@ class TerminalFilter(object): | |||
204 | self.interactive = False | 199 | self.interactive = False |
205 | bb.note("Unable to use interactive mode for this terminal, using fallback") | 200 | bb.note("Unable to use interactive mode for this terminal, using fallback") |
206 | return | 201 | return |
207 | if console: | 202 | |
208 | console.addFilter(InteractConsoleLogFilter(self)) | 203 | for h in handlers: |
209 | if errconsole: | 204 | h.addFilter(InteractConsoleLogFilter(self)) |
210 | errconsole.addFilter(InteractConsoleLogFilter(self)) | ||
211 | 205 | ||
212 | self.main_progress = None | 206 | self.main_progress = None |
213 | 207 | ||
@@ -411,6 +405,9 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
411 | "level": console_loglevel, | 405 | "level": console_loglevel, |
412 | "stream": "ext://sys.stdout", | 406 | "stream": "ext://sys.stdout", |
413 | "filters": ["BitBake.stdoutFilter"], | 407 | "filters": ["BitBake.stdoutFilter"], |
408 | ".": { | ||
409 | "is_console": True, | ||
410 | }, | ||
414 | }, | 411 | }, |
415 | "BitBake.errconsole": { | 412 | "BitBake.errconsole": { |
416 | "class": "logging.StreamHandler", | 413 | "class": "logging.StreamHandler", |
@@ -418,6 +415,9 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
418 | "level": loglevel, | 415 | "level": loglevel, |
419 | "stream": "ext://sys.stderr", | 416 | "stream": "ext://sys.stderr", |
420 | "filters": ["BitBake.stderrFilter"], | 417 | "filters": ["BitBake.stderrFilter"], |
418 | ".": { | ||
419 | "is_console": True, | ||
420 | }, | ||
421 | }, | 421 | }, |
422 | # This handler can be used if specific loggers should print on | 422 | # This handler can be used if specific loggers should print on |
423 | # the console at a lower severity than the default. It will | 423 | # the console at a lower severity than the default. It will |
@@ -430,6 +430,9 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
430 | "level": 1, | 430 | "level": 1, |
431 | "stream": "ext://sys.stdout", | 431 | "stream": "ext://sys.stdout", |
432 | "filters": ["BitBake.verbconsoleFilter"], | 432 | "filters": ["BitBake.verbconsoleFilter"], |
433 | ".": { | ||
434 | "is_console": True, | ||
435 | }, | ||
433 | }, | 436 | }, |
434 | }, | 437 | }, |
435 | "formatters": { | 438 | "formatters": { |
@@ -523,7 +526,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
523 | except OSError: | 526 | except OSError: |
524 | pass | 527 | pass |
525 | 528 | ||
526 | bb.msg.setLoggingConfig(logconfig, logconfigfile) | 529 | conf = bb.msg.setLoggingConfig(logconfig, logconfigfile) |
527 | 530 | ||
528 | if sys.stdin.isatty() and sys.stdout.isatty(): | 531 | if sys.stdin.isatty() and sys.stdout.isatty(): |
529 | log_exec_tty = True | 532 | log_exec_tty = True |
@@ -534,14 +537,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
534 | 537 | ||
535 | # Look for the specially designated handlers which need to be passed to the | 538 | # Look for the specially designated handlers which need to be passed to the |
536 | # terminal handler | 539 | # terminal handler |
537 | console = None | 540 | console_handlers = [h for h in conf.config['handlers'].values() if getattr(h, 'is_console', False)] |
538 | errconsole = None | ||
539 | for h in logger.handlers: | ||
540 | name = getattr(h, '_name', None) | ||
541 | if name == 'BitBake.console': | ||
542 | console = h | ||
543 | elif name == 'BitBake.errconsole': | ||
544 | errconsole = h | ||
545 | 541 | ||
546 | bb.utils.set_process_name("KnottyUI") | 542 | bb.utils.set_process_name("KnottyUI") |
547 | 543 | ||
@@ -591,7 +587,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
591 | printinterval = 5000 | 587 | printinterval = 5000 |
592 | lastprint = time.time() | 588 | lastprint = time.time() |
593 | 589 | ||
594 | termfilter = tf(main, helper, console, errconsole, params.options.quiet) | 590 | termfilter = tf(main, helper, console_handlers, params.options.quiet) |
595 | atexit.register(termfilter.finish) | 591 | atexit.register(termfilter.finish) |
596 | 592 | ||
597 | while True: | 593 | while True: |