aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/knotty.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-11-25 21:17:41 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-11-25 21:36:44 +0000
commit9be83df144a1675c8e7c9f0962e7e9e61ff767fd (patch)
treed19043f8a9241b3d70a66068a43e8540589e0bea /bitbake/lib/bb/ui/knotty.py
parent8a3dd9e9081d09f9c38c98b34f14bbd2a9b824a5 (diff)
downloadopenembedded-core-contrib-9be83df144a1675c8e7c9f0962e7e9e61ff767fd.tar.gz
bitbake: knotty/msg: Avoid usage of curses initscr/endwin to avoid terminal corruption
Using curses initscr/endwin causes screen corruption if for example you suspend bitbake and resume it. This changes the code to use a less invasive approach to determining colour availability on the terminal. (Bitbake rev: 4548a8f037eaf8d47a77052acc3e9ec264ac41e0) 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.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index a63d8b120e..be63e730f0 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -157,6 +157,8 @@ class TerminalFilter(object):
new[3] = new[3] & ~termios.ECHO
termios.tcsetattr(fd, termios.TCSADRAIN, new)
curses.setupterm()
+ if curses.tigetnum("colors") > 2:
+ format.enable_color()
self.ed = curses.tigetstr("ed")
if self.ed:
self.cuu = curses.tigetstr("cuu")
@@ -240,17 +242,15 @@ def main(server, eventHandler, tf = TerminalFilter):
console = logging.StreamHandler(sys.stdout)
format_str = "%(levelname)s: %(message)s"
format = bb.msg.BBLogFormatter(format_str)
- if interactive:
- format.enable_color()
bb.msg.addDefaultlogFilter(console)
console.setFormatter(format)
logger.addHandler(console)
if consolelogfile:
bb.utils.mkdirhier(os.path.dirname(consolelogfile))
- format = bb.msg.BBLogFormatter(format_str)
+ conlogformat = bb.msg.BBLogFormatter(format_str)
consolelog = logging.FileHandler(consolelogfile)
bb.msg.addDefaultlogFilter(consolelog)
- consolelog.setFormatter(format)
+ consolelog.setFormatter(conlogformat)
logger.addHandler(consolelog)
try: