Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # |
| 2 | # BitBake (No)TTY UI Implementation |
| 3 | # |
| 4 | # Handling output to TTYs or files (no TTY) |
| 5 | # |
| 6 | # Copyright (C) 2006-2012 Richard Purdie |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License version 2 as |
| 10 | # published by the Free Software Foundation. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License along |
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | |
| 21 | from __future__ import division |
| 22 | |
| 23 | import os |
| 24 | import sys |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 25 | import xmlrpc.client as xmlrpclib |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | import logging |
| 27 | import progressbar |
| 28 | import signal |
| 29 | import bb.msg |
| 30 | import time |
| 31 | import fcntl |
| 32 | import struct |
| 33 | import copy |
| 34 | import atexit |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 35 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | from bb.ui import uihelper |
| 37 | |
| 38 | featureSet = [bb.cooker.CookerFeatures.SEND_SANITYEVENTS] |
| 39 | |
| 40 | logger = logging.getLogger("BitBake") |
| 41 | interactive = sys.stdout.isatty() |
| 42 | |
| 43 | class BBProgress(progressbar.ProgressBar): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 44 | def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 45 | self.msg = msg |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 46 | self.extrapos = extrapos |
| 47 | if not widgets: |
| 48 | widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ', |
| 49 | progressbar.ETA()] |
| 50 | self.extrapos = 4 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 52 | if resize_handler: |
| 53 | self._resize_default = resize_handler |
| 54 | else: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | self._resize_default = signal.getsignal(signal.SIGWINCH) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets, fd=sys.stdout) |
| 57 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 58 | def _handle_resize(self, signum=None, frame=None): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | progressbar.ProgressBar._handle_resize(self, signum, frame) |
| 60 | if self._resize_default: |
| 61 | self._resize_default(signum, frame) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 62 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | def finish(self): |
| 64 | progressbar.ProgressBar.finish(self) |
| 65 | if self._resize_default: |
| 66 | signal.signal(signal.SIGWINCH, self._resize_default) |
| 67 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 68 | def setmessage(self, msg): |
| 69 | self.msg = msg |
| 70 | self.widgets[0] = msg |
| 71 | |
| 72 | def setextra(self, extra): |
| 73 | if self.extrapos > -1: |
| 74 | if extra: |
| 75 | extrastr = str(extra) |
| 76 | if extrastr[0] != ' ': |
| 77 | extrastr = ' ' + extrastr |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 78 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 79 | extrastr = '' |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 80 | self.widgets[self.extrapos] = extrastr |
| 81 | |
| 82 | def _need_update(self): |
| 83 | # We always want the bar to print when update() is called |
| 84 | return True |
| 85 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | class NonInteractiveProgress(object): |
| 87 | fobj = sys.stdout |
| 88 | |
| 89 | def __init__(self, msg, maxval): |
| 90 | self.msg = msg |
| 91 | self.maxval = maxval |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 92 | self.finished = False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 93 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 94 | def start(self, update=True): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | self.fobj.write("%s..." % self.msg) |
| 96 | self.fobj.flush() |
| 97 | return self |
| 98 | |
| 99 | def update(self, value): |
| 100 | pass |
| 101 | |
| 102 | def finish(self): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 103 | if self.finished: |
| 104 | return |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 105 | self.fobj.write("done.\n") |
| 106 | self.fobj.flush() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 107 | self.finished = True |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 | |
| 109 | def new_progress(msg, maxval): |
| 110 | if interactive: |
| 111 | return BBProgress(msg, maxval) |
| 112 | else: |
| 113 | return NonInteractiveProgress(msg, maxval) |
| 114 | |
| 115 | def pluralise(singular, plural, qty): |
| 116 | if(qty == 1): |
| 117 | return singular % qty |
| 118 | else: |
| 119 | return plural % qty |
| 120 | |
| 121 | |
| 122 | class InteractConsoleLogFilter(logging.Filter): |
| 123 | def __init__(self, tf, format): |
| 124 | self.tf = tf |
| 125 | self.format = format |
| 126 | |
| 127 | def filter(self, record): |
| 128 | if record.levelno == self.format.NOTE and (record.msg.startswith("Running") or record.msg.startswith("recipe ")): |
| 129 | return False |
| 130 | self.tf.clearFooter() |
| 131 | return True |
| 132 | |
| 133 | class TerminalFilter(object): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 134 | rows = 25 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 135 | columns = 80 |
| 136 | |
| 137 | def sigwinch_handle(self, signum, frame): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 138 | self.rows, self.columns = self.getTerminalColumns() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 139 | if self._sigwinch_default: |
| 140 | self._sigwinch_default(signum, frame) |
| 141 | |
| 142 | def getTerminalColumns(self): |
| 143 | def ioctl_GWINSZ(fd): |
| 144 | try: |
| 145 | cr = struct.unpack('hh', fcntl.ioctl(fd, self.termios.TIOCGWINSZ, '1234')) |
| 146 | except: |
| 147 | return None |
| 148 | return cr |
| 149 | cr = ioctl_GWINSZ(sys.stdout.fileno()) |
| 150 | if not cr: |
| 151 | try: |
| 152 | fd = os.open(os.ctermid(), os.O_RDONLY) |
| 153 | cr = ioctl_GWINSZ(fd) |
| 154 | os.close(fd) |
| 155 | except: |
| 156 | pass |
| 157 | if not cr: |
| 158 | try: |
| 159 | cr = (env['LINES'], env['COLUMNS']) |
| 160 | except: |
| 161 | cr = (25, 80) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 162 | return cr |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 163 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 164 | def __init__(self, main, helper, console, errconsole, format, quiet): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 165 | self.main = main |
| 166 | self.helper = helper |
| 167 | self.cuu = None |
| 168 | self.stdinbackup = None |
| 169 | self.interactive = sys.stdout.isatty() |
| 170 | self.footer_present = False |
| 171 | self.lastpids = [] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 172 | self.lasttime = None |
| 173 | self.quiet = quiet |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 174 | |
| 175 | if not self.interactive: |
| 176 | return |
| 177 | |
| 178 | try: |
| 179 | import curses |
| 180 | except ImportError: |
| 181 | sys.exit("FATAL: The knotty ui could not load the required curses python module.") |
| 182 | |
| 183 | import termios |
| 184 | self.curses = curses |
| 185 | self.termios = termios |
| 186 | try: |
| 187 | fd = sys.stdin.fileno() |
| 188 | self.stdinbackup = termios.tcgetattr(fd) |
| 189 | new = copy.deepcopy(self.stdinbackup) |
| 190 | new[3] = new[3] & ~termios.ECHO |
| 191 | termios.tcsetattr(fd, termios.TCSADRAIN, new) |
| 192 | curses.setupterm() |
| 193 | if curses.tigetnum("colors") > 2: |
| 194 | format.enable_color() |
| 195 | self.ed = curses.tigetstr("ed") |
| 196 | if self.ed: |
| 197 | self.cuu = curses.tigetstr("cuu") |
| 198 | try: |
| 199 | self._sigwinch_default = signal.getsignal(signal.SIGWINCH) |
| 200 | signal.signal(signal.SIGWINCH, self.sigwinch_handle) |
| 201 | except: |
| 202 | pass |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 203 | self.rows, self.columns = self.getTerminalColumns() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 204 | except: |
| 205 | self.cuu = None |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 206 | if not self.cuu: |
| 207 | self.interactive = False |
| 208 | bb.note("Unable to use interactive mode for this terminal, using fallback") |
| 209 | return |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 210 | if console: |
| 211 | console.addFilter(InteractConsoleLogFilter(self, format)) |
| 212 | if errconsole: |
| 213 | errconsole.addFilter(InteractConsoleLogFilter(self, format)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 214 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 215 | self.main_progress = None |
| 216 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 217 | def clearFooter(self): |
| 218 | if self.footer_present: |
| 219 | lines = self.footer_present |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 220 | sys.stdout.buffer.write(self.curses.tparm(self.cuu, lines)) |
| 221 | sys.stdout.buffer.write(self.curses.tparm(self.ed)) |
| 222 | sys.stdout.flush() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 223 | self.footer_present = False |
| 224 | |
| 225 | def updateFooter(self): |
| 226 | if not self.cuu: |
| 227 | return |
| 228 | activetasks = self.helper.running_tasks |
| 229 | failedtasks = self.helper.failed_tasks |
| 230 | runningpids = self.helper.running_pids |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 231 | currenttime = time.time() |
| 232 | if not self.lasttime or (currenttime - self.lasttime > 5): |
| 233 | self.helper.needUpdate = True |
| 234 | self.lasttime = currenttime |
| 235 | if self.footer_present and not self.helper.needUpdate: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 236 | return |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 237 | self.helper.needUpdate = False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 238 | if self.footer_present: |
| 239 | self.clearFooter() |
| 240 | if (not self.helper.tasknumber_total or self.helper.tasknumber_current == self.helper.tasknumber_total) and not len(activetasks): |
| 241 | return |
| 242 | tasks = [] |
| 243 | for t in runningpids: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 244 | progress = activetasks[t].get("progress", None) |
| 245 | if progress is not None: |
| 246 | pbar = activetasks[t].get("progressbar", None) |
| 247 | rate = activetasks[t].get("rate", None) |
| 248 | start_time = activetasks[t].get("starttime", None) |
| 249 | if not pbar or pbar.bouncing != (progress < 0): |
| 250 | if progress < 0: |
| 251 | pbar = BBProgress("0: %s (pid %s) " % (activetasks[t]["title"], t), 100, widgets=[progressbar.BouncingSlider(), ''], extrapos=2, resize_handler=self.sigwinch_handle) |
| 252 | pbar.bouncing = True |
| 253 | else: |
| 254 | pbar = BBProgress("0: %s (pid %s) " % (activetasks[t]["title"], t), 100, widgets=[progressbar.Percentage(), ' ', progressbar.Bar(), ''], extrapos=4, resize_handler=self.sigwinch_handle) |
| 255 | pbar.bouncing = False |
| 256 | activetasks[t]["progressbar"] = pbar |
| 257 | tasks.append((pbar, progress, rate, start_time)) |
| 258 | else: |
| 259 | start_time = activetasks[t].get("starttime", None) |
| 260 | if start_time: |
| 261 | tasks.append("%s - %ds (pid %s)" % (activetasks[t]["title"], currenttime - start_time, t)) |
| 262 | else: |
| 263 | tasks.append("%s (pid %s)" % (activetasks[t]["title"], t)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 264 | |
| 265 | if self.main.shutdown: |
| 266 | content = "Waiting for %s running tasks to finish:" % len(activetasks) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 267 | print(content) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 268 | else: |
| 269 | if self.quiet: |
| 270 | content = "Running tasks (%s of %s)" % (self.helper.tasknumber_current, self.helper.tasknumber_total) |
| 271 | elif not len(activetasks): |
| 272 | content = "No currently running tasks (%s of %s)" % (self.helper.tasknumber_current, self.helper.tasknumber_total) |
| 273 | else: |
| 274 | content = "Currently %2s running tasks (%s of %s)" % (len(activetasks), self.helper.tasknumber_current, self.helper.tasknumber_total) |
| 275 | maxtask = self.helper.tasknumber_total |
| 276 | if not self.main_progress or self.main_progress.maxval != maxtask: |
| 277 | widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()] |
| 278 | self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle) |
| 279 | self.main_progress.start(False) |
| 280 | self.main_progress.setmessage(content) |
| 281 | progress = self.helper.tasknumber_current - 1 |
| 282 | if progress < 0: |
| 283 | progress = 0 |
| 284 | content = self.main_progress.update(progress) |
| 285 | print('') |
| 286 | lines = 1 + int(len(content) / (self.columns + 1)) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 287 | if self.quiet == 0: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 288 | for tasknum, task in enumerate(tasks[:(self.rows - 2)]): |
| 289 | if isinstance(task, tuple): |
| 290 | pbar, progress, rate, start_time = task |
| 291 | if not pbar.start_time: |
| 292 | pbar.start(False) |
| 293 | if start_time: |
| 294 | pbar.start_time = start_time |
| 295 | pbar.setmessage('%s:%s' % (tasknum, pbar.msg.split(':', 1)[1])) |
| 296 | if progress > -1: |
| 297 | pbar.setextra(rate) |
| 298 | content = pbar.update(progress) |
| 299 | else: |
| 300 | content = pbar.update(1) |
| 301 | print('') |
| 302 | else: |
| 303 | content = "%s: %s" % (tasknum, task) |
| 304 | print(content) |
| 305 | lines = lines + 1 + int(len(content) / (self.columns + 1)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 306 | self.footer_present = lines |
| 307 | self.lastpids = runningpids[:] |
| 308 | self.lastcount = self.helper.tasknumber_current |
| 309 | |
| 310 | def finish(self): |
| 311 | if self.stdinbackup: |
| 312 | fd = sys.stdin.fileno() |
| 313 | self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup) |
| 314 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 315 | def 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 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 341 | def _log_settings_from_server(server, observe_only): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 342 | # Get values of variables which control our output |
| 343 | includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"]) |
| 344 | if error: |
| 345 | logger.error("Unable to get the value of BBINCLUDELOGS variable: %s" % error) |
| 346 | raise BaseException(error) |
| 347 | loglines, error = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"]) |
| 348 | if error: |
| 349 | logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s" % error) |
| 350 | raise BaseException(error) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 351 | if observe_only: |
| 352 | cmd = 'getVariable' |
| 353 | else: |
| 354 | cmd = 'getSetVariable' |
| 355 | consolelogfile, error = server.runCommand([cmd, "BB_CONSOLELOG"]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 356 | if error: |
| 357 | logger.error("Unable to get the value of BB_CONSOLELOG variable: %s" % error) |
| 358 | raise BaseException(error) |
| 359 | return includelogs, loglines, consolelogfile |
| 360 | |
| 361 | _evt_list = [ "bb.runqueue.runQueueExitWait", "bb.event.LogExecTTY", "logging.LogRecord", |
| 362 | "bb.build.TaskFailed", "bb.build.TaskBase", "bb.event.ParseStarted", |
| 363 | "bb.event.ParseProgress", "bb.event.ParseCompleted", "bb.event.CacheLoadStarted", |
| 364 | "bb.event.CacheLoadProgress", "bb.event.CacheLoadCompleted", "bb.command.CommandFailed", |
| 365 | "bb.command.CommandExit", "bb.command.CommandCompleted", "bb.cooker.CookerExit", |
| 366 | "bb.event.MultipleProviders", "bb.event.NoProvider", "bb.runqueue.sceneQueueTaskStarted", |
| 367 | "bb.runqueue.runQueueTaskStarted", "bb.runqueue.runQueueTaskFailed", "bb.runqueue.sceneQueueTaskFailed", |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 368 | "bb.event.BuildBase", "bb.build.TaskStarted", "bb.build.TaskSucceeded", "bb.build.TaskFailedSilent", |
| 369 | "bb.build.TaskProgress", "bb.event.ProcessStarted", "bb.event.ProcessProgress", "bb.event.ProcessFinished"] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 370 | |
| 371 | def main(server, eventHandler, params, tf = TerminalFilter): |
| 372 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 373 | if not params.observe_only: |
| 374 | params.updateToServer(server, os.environ.copy()) |
| 375 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 376 | includelogs, loglines, consolelogfile = _log_settings_from_server(server, params.observe_only) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 377 | |
| 378 | if sys.stdin.isatty() and sys.stdout.isatty(): |
| 379 | log_exec_tty = True |
| 380 | else: |
| 381 | log_exec_tty = False |
| 382 | |
| 383 | helper = uihelper.BBUIHelper() |
| 384 | |
| 385 | console = logging.StreamHandler(sys.stdout) |
| 386 | errconsole = logging.StreamHandler(sys.stderr) |
| 387 | format_str = "%(levelname)s: %(message)s" |
| 388 | format = bb.msg.BBLogFormatter(format_str) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 389 | if params.options.quiet == 0: |
| 390 | forcelevel = None |
| 391 | elif params.options.quiet > 2: |
| 392 | forcelevel = bb.msg.BBLogFormatter.ERROR |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 393 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 394 | forcelevel = bb.msg.BBLogFormatter.WARNING |
| 395 | bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, forcelevel) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 396 | bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr) |
| 397 | console.setFormatter(format) |
| 398 | errconsole.setFormatter(format) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 399 | if not bb.msg.has_console_handler(logger): |
| 400 | logger.addHandler(console) |
| 401 | logger.addHandler(errconsole) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 402 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 403 | bb.utils.set_process_name("KnottyUI") |
| 404 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 405 | if params.options.remote_server and params.options.kill_server: |
| 406 | server.terminateServer() |
| 407 | return |
| 408 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 409 | consolelog = None |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 410 | if consolelogfile and not params.options.show_environment and not params.options.show_versions: |
| 411 | bb.utils.mkdirhier(os.path.dirname(consolelogfile)) |
| 412 | conlogformat = bb.msg.BBLogFormatter(format_str) |
| 413 | consolelog = logging.FileHandler(consolelogfile) |
| 414 | bb.msg.addDefaultlogFilter(consolelog) |
| 415 | consolelog.setFormatter(conlogformat) |
| 416 | logger.addHandler(consolelog) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 417 | loglink = os.path.join(os.path.dirname(consolelogfile), 'console-latest.log') |
| 418 | bb.utils.remove(loglink) |
| 419 | try: |
| 420 | os.symlink(os.path.basename(consolelogfile), loglink) |
| 421 | except OSError: |
| 422 | pass |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 423 | |
| 424 | llevel, debug_domains = bb.msg.constructLogOptions() |
| 425 | server.runCommand(["setEventMask", server.getEventHandle(), llevel, debug_domains, _evt_list]) |
| 426 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 427 | universe = False |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 428 | if not params.observe_only: |
| 429 | params.updateFromServer(server) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 430 | cmdline = params.parseActions() |
| 431 | if not cmdline: |
| 432 | print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") |
| 433 | return 1 |
| 434 | if 'msg' in cmdline and cmdline['msg']: |
| 435 | logger.error(cmdline['msg']) |
| 436 | return 1 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 437 | if cmdline['action'][0] == "buildTargets" and "universe" in cmdline['action'][1]: |
| 438 | universe = True |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 439 | |
| 440 | ret, error = server.runCommand(cmdline['action']) |
| 441 | if error: |
| 442 | logger.error("Command '%s' failed: %s" % (cmdline, error)) |
| 443 | return 1 |
| 444 | elif ret != True: |
| 445 | logger.error("Command '%s' failed: returned %s" % (cmdline, ret)) |
| 446 | return 1 |
| 447 | |
| 448 | |
| 449 | parseprogress = None |
| 450 | cacheprogress = None |
| 451 | main.shutdown = 0 |
| 452 | interrupted = False |
| 453 | return_value = 0 |
| 454 | errors = 0 |
| 455 | warnings = 0 |
| 456 | taskfailures = [] |
| 457 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 458 | termfilter = tf(main, helper, console, errconsole, format, params.options.quiet) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 459 | atexit.register(termfilter.finish) |
| 460 | |
| 461 | while True: |
| 462 | try: |
| 463 | event = eventHandler.waitEvent(0) |
| 464 | if event is None: |
| 465 | if main.shutdown > 1: |
| 466 | break |
| 467 | termfilter.updateFooter() |
| 468 | event = eventHandler.waitEvent(0.25) |
| 469 | if event is None: |
| 470 | continue |
| 471 | helper.eventHandler(event) |
| 472 | if isinstance(event, bb.runqueue.runQueueExitWait): |
| 473 | if not main.shutdown: |
| 474 | main.shutdown = 1 |
| 475 | continue |
| 476 | if isinstance(event, bb.event.LogExecTTY): |
| 477 | if log_exec_tty: |
| 478 | tries = event.retries |
| 479 | while tries: |
| 480 | print("Trying to run: %s" % event.prog) |
| 481 | if os.system(event.prog) == 0: |
| 482 | break |
| 483 | time.sleep(event.sleep_delay) |
| 484 | tries -= 1 |
| 485 | if tries: |
| 486 | continue |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 487 | logger.warning(event.msg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 488 | continue |
| 489 | |
| 490 | if isinstance(event, logging.LogRecord): |
| 491 | if event.levelno >= format.ERROR: |
| 492 | errors = errors + 1 |
| 493 | return_value = 1 |
| 494 | elif event.levelno == format.WARNING: |
| 495 | warnings = warnings + 1 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 496 | |
| 497 | if event.taskpid != 0: |
| 498 | # For "normal" logging conditions, don't show note logs from tasks |
| 499 | # but do show them if the user has changed the default log level to |
| 500 | # include verbose/debug messages |
| 501 | if event.levelno <= format.NOTE and (event.levelno < llevel or (event.levelno == format.NOTE and llevel != format.VERBOSE)): |
| 502 | continue |
| 503 | |
| 504 | # Prefix task messages with recipe/task |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 505 | if event.taskpid in helper.running_tasks and event.levelno != format.PLAIN: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 506 | taskinfo = helper.running_tasks[event.taskpid] |
| 507 | event.msg = taskinfo['title'] + ': ' + event.msg |
| 508 | if hasattr(event, 'fn'): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 509 | event.msg = event.fn + ': ' + event.msg |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 510 | logger.handle(event) |
| 511 | continue |
| 512 | |
| 513 | if isinstance(event, bb.build.TaskFailedSilent): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 514 | logger.warning("Logfile for failed setscene task is %s" % event.logfile) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 515 | continue |
| 516 | if isinstance(event, bb.build.TaskFailed): |
| 517 | return_value = 1 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 518 | print_event_log(event, includelogs, loglines, termfilter) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 519 | if isinstance(event, bb.build.TaskBase): |
| 520 | logger.info(event._message) |
| 521 | continue |
| 522 | if isinstance(event, bb.event.ParseStarted): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 523 | if params.options.quiet > 1: |
| 524 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 525 | if event.total == 0: |
| 526 | continue |
| 527 | parseprogress = new_progress("Parsing recipes", event.total).start() |
| 528 | continue |
| 529 | if isinstance(event, bb.event.ParseProgress): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 530 | if params.options.quiet > 1: |
| 531 | continue |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 532 | if parseprogress: |
| 533 | parseprogress.update(event.current) |
| 534 | else: |
| 535 | bb.warn("Got ParseProgress event for parsing that never started?") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 536 | continue |
| 537 | if isinstance(event, bb.event.ParseCompleted): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 538 | if params.options.quiet > 1: |
| 539 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 540 | if not parseprogress: |
| 541 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 542 | parseprogress.finish() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 543 | pasreprogress = None |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 544 | if params.options.quiet == 0: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 545 | print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." |
| 546 | % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 547 | continue |
| 548 | |
| 549 | if isinstance(event, bb.event.CacheLoadStarted): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 550 | if params.options.quiet > 1: |
| 551 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 552 | cacheprogress = new_progress("Loading cache", event.total).start() |
| 553 | continue |
| 554 | if isinstance(event, bb.event.CacheLoadProgress): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 555 | if params.options.quiet > 1: |
| 556 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 557 | cacheprogress.update(event.current) |
| 558 | continue |
| 559 | if isinstance(event, bb.event.CacheLoadCompleted): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 560 | if params.options.quiet > 1: |
| 561 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 562 | cacheprogress.finish() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 563 | if params.options.quiet == 0: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 564 | print("Loaded %d entries from dependency cache." % event.num_entries) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 565 | continue |
| 566 | |
| 567 | if isinstance(event, bb.command.CommandFailed): |
| 568 | return_value = event.exitcode |
| 569 | if event.error: |
| 570 | errors = errors + 1 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 571 | logger.error(str(event)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 572 | main.shutdown = 2 |
| 573 | continue |
| 574 | if isinstance(event, bb.command.CommandExit): |
| 575 | if not return_value: |
| 576 | return_value = event.exitcode |
| 577 | continue |
| 578 | if isinstance(event, (bb.command.CommandCompleted, bb.cooker.CookerExit)): |
| 579 | main.shutdown = 2 |
| 580 | continue |
| 581 | if isinstance(event, bb.event.MultipleProviders): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 582 | logger.info(str(event)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 583 | continue |
| 584 | if isinstance(event, bb.event.NoProvider): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 585 | # For universe builds, only show these as warnings, not errors |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 586 | if not universe: |
| 587 | return_value = 1 |
| 588 | errors = errors + 1 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 589 | logger.error(str(event)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 590 | else: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 591 | logger.warning(str(event)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 592 | continue |
| 593 | |
| 594 | if isinstance(event, bb.runqueue.sceneQueueTaskStarted): |
| 595 | logger.info("Running setscene task %d of %d (%s)" % (event.stats.completed + event.stats.active + event.stats.failed + 1, event.stats.total, event.taskstring)) |
| 596 | continue |
| 597 | |
| 598 | if isinstance(event, bb.runqueue.runQueueTaskStarted): |
| 599 | if event.noexec: |
| 600 | tasktype = 'noexec task' |
| 601 | else: |
| 602 | tasktype = 'task' |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 603 | logger.info("Running %s %d of %d (%s)", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 604 | tasktype, |
| 605 | event.stats.completed + event.stats.active + |
| 606 | event.stats.failed + 1, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 607 | event.stats.total, event.taskstring) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 608 | continue |
| 609 | |
| 610 | if isinstance(event, bb.runqueue.runQueueTaskFailed): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 611 | return_value = 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 612 | taskfailures.append(event.taskstring) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 613 | logger.error(str(event)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 614 | continue |
| 615 | |
| 616 | if isinstance(event, bb.runqueue.sceneQueueTaskFailed): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 617 | logger.warning(str(event)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 618 | continue |
| 619 | |
| 620 | if isinstance(event, bb.event.DepTreeGenerated): |
| 621 | continue |
| 622 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 623 | if isinstance(event, bb.event.ProcessStarted): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 624 | if params.options.quiet > 1: |
| 625 | continue |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 626 | parseprogress = new_progress(event.processname, event.total) |
| 627 | parseprogress.start(False) |
| 628 | continue |
| 629 | if isinstance(event, bb.event.ProcessProgress): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 630 | if params.options.quiet > 1: |
| 631 | continue |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 632 | if parseprogress: |
| 633 | parseprogress.update(event.progress) |
| 634 | else: |
| 635 | bb.warn("Got ProcessProgress event for someting that never started?") |
| 636 | continue |
| 637 | if isinstance(event, bb.event.ProcessFinished): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 638 | if params.options.quiet > 1: |
| 639 | continue |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 640 | if parseprogress: |
| 641 | parseprogress.finish() |
| 642 | parseprogress = None |
| 643 | continue |
| 644 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 645 | # ignore |
| 646 | if isinstance(event, (bb.event.BuildBase, |
| 647 | bb.event.MetadataEvent, |
| 648 | bb.event.StampUpdate, |
| 649 | bb.event.ConfigParsed, |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 650 | bb.event.MultiConfigParsed, |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 651 | bb.event.RecipeParsed, |
| 652 | bb.event.RecipePreFinalise, |
| 653 | bb.runqueue.runQueueEvent, |
| 654 | bb.event.OperationStarted, |
| 655 | bb.event.OperationCompleted, |
| 656 | bb.event.OperationProgress, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 657 | bb.event.DiskFull, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 658 | bb.event.HeartbeatEvent, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 659 | bb.build.TaskProgress)): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 660 | continue |
| 661 | |
| 662 | logger.error("Unknown event: %s", event) |
| 663 | |
| 664 | except EnvironmentError as ioerror: |
| 665 | termfilter.clearFooter() |
| 666 | # ignore interrupted io |
| 667 | if ioerror.args[0] == 4: |
| 668 | continue |
| 669 | sys.stderr.write(str(ioerror)) |
| 670 | if not params.observe_only: |
| 671 | _, error = server.runCommand(["stateForceShutdown"]) |
| 672 | main.shutdown = 2 |
| 673 | except KeyboardInterrupt: |
| 674 | termfilter.clearFooter() |
| 675 | if params.observe_only: |
| 676 | print("\nKeyboard Interrupt, exiting observer...") |
| 677 | main.shutdown = 2 |
| 678 | if not params.observe_only and main.shutdown == 1: |
| 679 | print("\nSecond Keyboard Interrupt, stopping...\n") |
| 680 | _, error = server.runCommand(["stateForceShutdown"]) |
| 681 | if error: |
| 682 | logger.error("Unable to cleanly stop: %s" % error) |
| 683 | if not params.observe_only and main.shutdown == 0: |
| 684 | print("\nKeyboard Interrupt, closing down...\n") |
| 685 | interrupted = True |
| 686 | _, error = server.runCommand(["stateShutdown"]) |
| 687 | if error: |
| 688 | logger.error("Unable to cleanly shutdown: %s" % error) |
| 689 | main.shutdown = main.shutdown + 1 |
| 690 | pass |
| 691 | except Exception as e: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 692 | import traceback |
| 693 | sys.stderr.write(traceback.format_exc()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 694 | if not params.observe_only: |
| 695 | _, error = server.runCommand(["stateForceShutdown"]) |
| 696 | main.shutdown = 2 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 697 | return_value = 1 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 698 | try: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 699 | termfilter.clearFooter() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 700 | summary = "" |
| 701 | if taskfailures: |
| 702 | summary += pluralise("\nSummary: %s task failed:", |
| 703 | "\nSummary: %s tasks failed:", len(taskfailures)) |
| 704 | for failure in taskfailures: |
| 705 | summary += "\n %s" % failure |
| 706 | if warnings: |
| 707 | summary += pluralise("\nSummary: There was %s WARNING message shown.", |
| 708 | "\nSummary: There were %s WARNING messages shown.", warnings) |
| 709 | if return_value and errors: |
| 710 | summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.", |
| 711 | "\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 712 | if summary and params.options.quiet == 0: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 713 | print(summary) |
| 714 | |
| 715 | if interrupted: |
| 716 | print("Execution was interrupted, returning a non-zero exit code.") |
| 717 | if return_value == 0: |
| 718 | return_value = 1 |
| 719 | except IOError as e: |
| 720 | import errno |
| 721 | if e.errno == errno.EPIPE: |
| 722 | pass |
| 723 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 724 | if consolelog: |
| 725 | logger.removeHandler(consolelog) |
| 726 | consolelog.close() |
| 727 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 728 | return return_value |