diff options
| author | Jason Wessel <jason.wessel@windriver.com> | 2012-09-17 17:43:49 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-09-24 15:35:32 +0100 |
| commit | 98ac5e4e6230095487b819b911890ec64e28d5f7 (patch) | |
| tree | c25e92de41ccdeca570fb3a7b744c0b3327f2c17 | |
| parent | eab93b0d625aba061a73b9c5f7ce7828495f1338 (diff) | |
| download | poky-98ac5e4e6230095487b819b911890ec64e28d5f7.tar.gz | |
bitbake: event.py, knotty.py, ncurses.py, runningbuild.py: Add support for LogExecTTY event
The LogExecTTY even is intended to provide the ability to spawn a task
on a the controlling tty, if a tty is availble. When a controlling
tty is not availble the previous behavior is preserved where a warning
is issued about the action an end user must execute.
All the available UI's were tested against the new event type.
This feature is primarily intended for hooking up a screen client
session automatically on the controlling tty to allow for a more
streamlined end user experience when using a pure command line driven
environment. The changes that send the LogExecTTY event are in the
oe-core side.
(Bitbake rev: cffe80d82a46aaf52ff4a7b6409435754043553f)
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | bitbake/lib/bb/event.py | 9 | ||||
| -rw-r--r-- | bitbake/lib/bb/ui/crumbs/runningbuild.py | 15 | ||||
| -rw-r--r-- | bitbake/lib/bb/ui/knotty.py | 19 | ||||
| -rw-r--r-- | bitbake/lib/bb/ui/ncurses.py | 2 |
4 files changed, 45 insertions, 0 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index 7ee28fcfcb..deb1c21595 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
| @@ -510,6 +510,15 @@ class MsgFatal(MsgBase): | |||
| 510 | class MsgPlain(MsgBase): | 510 | class MsgPlain(MsgBase): |
| 511 | """General output""" | 511 | """General output""" |
| 512 | 512 | ||
| 513 | class LogExecTTY(Event): | ||
| 514 | """Send event containing program to spawn on tty of the logger""" | ||
| 515 | def __init__(self, msg, prog, sleep_delay, retries): | ||
| 516 | Event.__init__(self) | ||
| 517 | self.msg = msg | ||
| 518 | self.prog = prog | ||
| 519 | self.sleep_delay = sleep_delay | ||
| 520 | self.retries = retries | ||
| 521 | |||
| 513 | class LogHandler(logging.Handler): | 522 | class LogHandler(logging.Handler): |
| 514 | """Dispatch logging messages as bitbake events""" | 523 | """Dispatch logging messages as bitbake events""" |
| 515 | 524 | ||
diff --git a/bitbake/lib/bb/ui/crumbs/runningbuild.py b/bitbake/lib/bb/ui/crumbs/runningbuild.py index a57d6db5e5..700fd65015 100644 --- a/bitbake/lib/bb/ui/crumbs/runningbuild.py +++ b/bitbake/lib/bb/ui/crumbs/runningbuild.py | |||
| @@ -375,6 +375,21 @@ class RunningBuild (gobject.GObject): | |||
| 375 | msg += ("%s\n" % reason) | 375 | msg += ("%s\n" % reason) |
| 376 | self.emit("no-provider", msg) | 376 | self.emit("no-provider", msg) |
| 377 | self.emit("log", msg) | 377 | self.emit("log", msg) |
| 378 | elif isinstance(event, bb.event.LogExecTTY): | ||
| 379 | icon = "dialog-warning" | ||
| 380 | color = HobColors.WARNING | ||
| 381 | if self.sequential or not parent: | ||
| 382 | tree_add = self.model.append | ||
| 383 | else: | ||
| 384 | tree_add = self.model.prepend | ||
| 385 | tree_add(parent, | ||
| 386 | (None, | ||
| 387 | package, | ||
| 388 | task, | ||
| 389 | event.msg, | ||
| 390 | icon, | ||
| 391 | color, | ||
| 392 | 0)) | ||
| 378 | else: | 393 | else: |
| 379 | if not isinstance(event, (bb.event.BuildBase, | 394 | if not isinstance(event, (bb.event.BuildBase, |
| 380 | bb.event.StampUpdate, | 395 | bb.event.StampUpdate, |
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 858cacfe55..d81ad5d540 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py | |||
| @@ -27,6 +27,7 @@ import logging | |||
| 27 | import progressbar | 27 | import progressbar |
| 28 | import signal | 28 | import signal |
| 29 | import bb.msg | 29 | import bb.msg |
| 30 | import time | ||
| 30 | import fcntl | 31 | import fcntl |
| 31 | import struct | 32 | import struct |
| 32 | import copy | 33 | import copy |
| @@ -216,6 +217,10 @@ def main(server, eventHandler, tf = TerminalFilter): | |||
| 216 | includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"]) | 217 | includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"]) |
| 217 | loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"]) | 218 | loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"]) |
| 218 | consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"]) | 219 | consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"]) |
| 220 | if sys.stdin.isatty() and sys.stdout.isatty(): | ||
| 221 | log_exec_tty = True | ||
| 222 | else: | ||
| 223 | log_exec_tty = False | ||
| 219 | 224 | ||
| 220 | helper = uihelper.BBUIHelper() | 225 | helper = uihelper.BBUIHelper() |
| 221 | 226 | ||
| @@ -271,6 +276,20 @@ def main(server, eventHandler, tf = TerminalFilter): | |||
| 271 | if not main.shutdown: | 276 | if not main.shutdown: |
| 272 | main.shutdown = 1 | 277 | main.shutdown = 1 |
| 273 | 278 | ||
| 279 | if isinstance(event, bb.event.LogExecTTY): | ||
| 280 | if log_exec_tty: | ||
| 281 | tries = event.retries | ||
| 282 | while tries: | ||
| 283 | print "Trying to run: %s" % event.prog | ||
| 284 | if os.system(event.prog) == 0: | ||
| 285 | break | ||
| 286 | time.sleep(event.sleep_delay) | ||
| 287 | tries -= 1 | ||
| 288 | if tries: | ||
| 289 | continue | ||
| 290 | logger.warn(event.msg) | ||
| 291 | continue | ||
| 292 | |||
| 274 | if isinstance(event, logging.LogRecord): | 293 | if isinstance(event, logging.LogRecord): |
| 275 | if event.levelno >= format.ERROR: | 294 | if event.levelno >= format.ERROR: |
| 276 | errors = errors + 1 | 295 | errors = errors + 1 |
diff --git a/bitbake/lib/bb/ui/ncurses.py b/bitbake/lib/bb/ui/ncurses.py index f573b95574..f6ea7f9bca 100644 --- a/bitbake/lib/bb/ui/ncurses.py +++ b/bitbake/lib/bb/ui/ncurses.py | |||
| @@ -318,6 +318,8 @@ class NCursesUI: | |||
| 318 | if isinstance(event, bb.cooker.CookerExit): | 318 | if isinstance(event, bb.cooker.CookerExit): |
| 319 | exitflag = True | 319 | exitflag = True |
| 320 | 320 | ||
| 321 | if isinstance(event, bb.event.LogExecTTY): | ||
| 322 | mw.appendText('WARN: ' + event.msg + '\n') | ||
| 321 | if helper.needUpdate: | 323 | if helper.needUpdate: |
| 322 | activetasks, failedtasks = helper.getTasks() | 324 | activetasks, failedtasks = helper.getTasks() |
| 323 | taw.erase() | 325 | taw.erase() |
