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>
This commit is contained in:
parent
eab93b0d62
commit
98ac5e4e62
|
@ -510,6 +510,15 @@ class MsgFatal(MsgBase):
|
||||||
class MsgPlain(MsgBase):
|
class MsgPlain(MsgBase):
|
||||||
"""General output"""
|
"""General output"""
|
||||||
|
|
||||||
|
class LogExecTTY(Event):
|
||||||
|
"""Send event containing program to spawn on tty of the logger"""
|
||||||
|
def __init__(self, msg, prog, sleep_delay, retries):
|
||||||
|
Event.__init__(self)
|
||||||
|
self.msg = msg
|
||||||
|
self.prog = prog
|
||||||
|
self.sleep_delay = sleep_delay
|
||||||
|
self.retries = retries
|
||||||
|
|
||||||
class LogHandler(logging.Handler):
|
class LogHandler(logging.Handler):
|
||||||
"""Dispatch logging messages as bitbake events"""
|
"""Dispatch logging messages as bitbake events"""
|
||||||
|
|
||||||
|
|
|
@ -375,6 +375,21 @@ class RunningBuild (gobject.GObject):
|
||||||
msg += ("%s\n" % reason)
|
msg += ("%s\n" % reason)
|
||||||
self.emit("no-provider", msg)
|
self.emit("no-provider", msg)
|
||||||
self.emit("log", msg)
|
self.emit("log", msg)
|
||||||
|
elif isinstance(event, bb.event.LogExecTTY):
|
||||||
|
icon = "dialog-warning"
|
||||||
|
color = HobColors.WARNING
|
||||||
|
if self.sequential or not parent:
|
||||||
|
tree_add = self.model.append
|
||||||
|
else:
|
||||||
|
tree_add = self.model.prepend
|
||||||
|
tree_add(parent,
|
||||||
|
(None,
|
||||||
|
package,
|
||||||
|
task,
|
||||||
|
event.msg,
|
||||||
|
icon,
|
||||||
|
color,
|
||||||
|
0))
|
||||||
else:
|
else:
|
||||||
if not isinstance(event, (bb.event.BuildBase,
|
if not isinstance(event, (bb.event.BuildBase,
|
||||||
bb.event.StampUpdate,
|
bb.event.StampUpdate,
|
||||||
|
|
|
@ -27,6 +27,7 @@ import logging
|
||||||
import progressbar
|
import progressbar
|
||||||
import signal
|
import signal
|
||||||
import bb.msg
|
import bb.msg
|
||||||
|
import time
|
||||||
import fcntl
|
import fcntl
|
||||||
import struct
|
import struct
|
||||||
import copy
|
import copy
|
||||||
|
@ -216,6 +217,10 @@ def main(server, eventHandler, tf = TerminalFilter):
|
||||||
includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"])
|
includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"])
|
||||||
loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
|
loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
|
||||||
consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"])
|
consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"])
|
||||||
|
if sys.stdin.isatty() and sys.stdout.isatty():
|
||||||
|
log_exec_tty = True
|
||||||
|
else:
|
||||||
|
log_exec_tty = False
|
||||||
|
|
||||||
helper = uihelper.BBUIHelper()
|
helper = uihelper.BBUIHelper()
|
||||||
|
|
||||||
|
@ -271,6 +276,20 @@ def main(server, eventHandler, tf = TerminalFilter):
|
||||||
if not main.shutdown:
|
if not main.shutdown:
|
||||||
main.shutdown = 1
|
main.shutdown = 1
|
||||||
|
|
||||||
|
if isinstance(event, bb.event.LogExecTTY):
|
||||||
|
if log_exec_tty:
|
||||||
|
tries = event.retries
|
||||||
|
while tries:
|
||||||
|
print "Trying to run: %s" % event.prog
|
||||||
|
if os.system(event.prog) == 0:
|
||||||
|
break
|
||||||
|
time.sleep(event.sleep_delay)
|
||||||
|
tries -= 1
|
||||||
|
if tries:
|
||||||
|
continue
|
||||||
|
logger.warn(event.msg)
|
||||||
|
continue
|
||||||
|
|
||||||
if isinstance(event, logging.LogRecord):
|
if isinstance(event, logging.LogRecord):
|
||||||
if event.levelno >= format.ERROR:
|
if event.levelno >= format.ERROR:
|
||||||
errors = errors + 1
|
errors = errors + 1
|
||||||
|
|
|
@ -318,6 +318,8 @@ class NCursesUI:
|
||||||
if isinstance(event, bb.cooker.CookerExit):
|
if isinstance(event, bb.cooker.CookerExit):
|
||||||
exitflag = True
|
exitflag = True
|
||||||
|
|
||||||
|
if isinstance(event, bb.event.LogExecTTY):
|
||||||
|
mw.appendText('WARN: ' + event.msg + '\n')
|
||||||
if helper.needUpdate:
|
if helper.needUpdate:
|
||||||
activetasks, failedtasks = helper.getTasks()
|
activetasks, failedtasks = helper.getTasks()
|
||||||
taw.erase()
|
taw.erase()
|
||||||
|
|
Loading…
Reference in New Issue