summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/msg.py12
-rw-r--r--bitbake/lib/bb/ui/knotty.py8
2 files changed, 5 insertions, 15 deletions
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index 007c95a4ea..e70daee92f 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -106,17 +106,7 @@ class BBLogFormatter(logging.Formatter):
106 return record 106 return record
107 107
108 def enable_color(self): 108 def enable_color(self):
109 import curses 109 self.color_enabled = True
110 try:
111 win = None
112 win = curses.initscr()
113 if curses.has_colors():
114 self.color_enabled = True
115 except:
116 pass
117 finally:
118 if win is not None:
119 curses.endwin()
120 110
121class BBLogFilter(object): 111class BBLogFilter(object):
122 def __init__(self, handler, level, debug_domains): 112 def __init__(self, handler, level, debug_domains):
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):
157 new[3] = new[3] & ~termios.ECHO 157 new[3] = new[3] & ~termios.ECHO
158 termios.tcsetattr(fd, termios.TCSADRAIN, new) 158 termios.tcsetattr(fd, termios.TCSADRAIN, new)
159 curses.setupterm() 159 curses.setupterm()
160 if curses.tigetnum("colors") > 2:
161 format.enable_color()
160 self.ed = curses.tigetstr("ed") 162 self.ed = curses.tigetstr("ed")
161 if self.ed: 163 if self.ed:
162 self.cuu = curses.tigetstr("cuu") 164 self.cuu = curses.tigetstr("cuu")
@@ -240,17 +242,15 @@ def main(server, eventHandler, tf = TerminalFilter):
240 console = logging.StreamHandler(sys.stdout) 242 console = logging.StreamHandler(sys.stdout)
241 format_str = "%(levelname)s: %(message)s" 243 format_str = "%(levelname)s: %(message)s"
242 format = bb.msg.BBLogFormatter(format_str) 244 format = bb.msg.BBLogFormatter(format_str)
243 if interactive:
244 format.enable_color()
245 bb.msg.addDefaultlogFilter(console) 245 bb.msg.addDefaultlogFilter(console)
246 console.setFormatter(format) 246 console.setFormatter(format)
247 logger.addHandler(console) 247 logger.addHandler(console)
248 if consolelogfile: 248 if consolelogfile:
249 bb.utils.mkdirhier(os.path.dirname(consolelogfile)) 249 bb.utils.mkdirhier(os.path.dirname(consolelogfile))
250 format = bb.msg.BBLogFormatter(format_str) 250 conlogformat = bb.msg.BBLogFormatter(format_str)
251 consolelog = logging.FileHandler(consolelogfile) 251 consolelog = logging.FileHandler(consolelogfile)
252 bb.msg.addDefaultlogFilter(consolelog) 252 bb.msg.addDefaultlogFilter(consolelog)
253 consolelog.setFormatter(format) 253 consolelog.setFormatter(conlogformat)
254 logger.addHandler(consolelog) 254 logger.addHandler(consolelog)
255 255
256 try: 256 try: