1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 01:19:52 +00:00

Queue up events before the UI is spawned

- Queue up any events fired to the UI before the UI exists
- At exit, check if UIs exist, and if not, flush the queue of LogRecords to
  the console directly.
- When establishing a connection from the UI to the server, flush the queue of
  events to the queue in the server connection, so the UI will receive them
  when it begins its event loop.

(Bitbake rev: 73488aeb317ed306f2ecf99cc9d3708526a5933c)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
Chris Larson
2010-09-28 08:24:55 -07:00
committed by Richard Purdie
parent 30cef6bade
commit 26eda93337
4 changed files with 78 additions and 51 deletions
+53 -51
View File
@@ -494,69 +494,71 @@ class BBCooker:
path, _ = os.path.split(path) path, _ = os.path.split(path)
def parseConfigurationFiles(self, files): def parseConfigurationFiles(self, files):
try: def _parse(f, data):
data = self.configuration.data try:
return bb.parse.handle(f, data)
except (IOError, bb.parse.ParseError) as exc:
parselog.critical("Unable to parse %s: %s" % (f, exc))
sys.exit(1)
data = self.configuration.data
bb.parse.init_parser(data, self.configuration.dump_signatures) bb.parse.init_parser(data, self.configuration.dump_signatures)
for f in files: for f in files:
data = bb.parse.handle(f, data) data = _parse(f, data)
layerconf = self._findLayerConf() layerconf = self._findLayerConf()
if layerconf: if layerconf:
parselog.debug(2, "Found bblayers.conf (%s)", layerconf) parselog.debug(2, "Found bblayers.conf (%s)", layerconf)
data = bb.parse.handle(layerconf, data) data = _parse(layerconf, data)
layers = (bb.data.getVar('BBLAYERS', data, True) or "").split() layers = (bb.data.getVar('BBLAYERS', data, True) or "").split()
data = bb.data.createCopy(data) data = bb.data.createCopy(data)
for layer in layers: for layer in layers:
parselog.debug(2, "Adding layer %s", layer) parselog.debug(2, "Adding layer %s", layer)
bb.data.setVar('LAYERDIR', layer, data) bb.data.setVar('LAYERDIR', layer, data)
data = bb.parse.handle(os.path.join(layer, "conf", "layer.conf"), data) data = _parse(os.path.join(layer, "conf", "layer.conf"), data)
# XXX: Hack, relies on the local keys of the datasmart # XXX: Hack, relies on the local keys of the datasmart
# instance being stored in the 'dict' attribute and makes # instance being stored in the 'dict' attribute and makes
# assumptions about how variable expansion works, but # assumptions about how variable expansion works, but
# there's no better way to force an expansion of a single # there's no better way to force an expansion of a single
# variable across the datastore today, and this at least # variable across the datastore today, and this at least
# lets us reference LAYERDIR without having to immediately # lets us reference LAYERDIR without having to immediately
# eval all our variables that use it. # eval all our variables that use it.
for key in data.dict: for key in data.dict:
if key != "_data": if key != "_data":
value = data.getVar(key, False) value = data.getVar(key, False)
if value and "${LAYERDIR}" in value: if value and "${LAYERDIR}" in value:
data.setVar(key, value.replace("${LAYERDIR}", layer)) data.setVar(key, value.replace("${LAYERDIR}", layer))
bb.data.delVar('LAYERDIR', data) bb.data.delVar('LAYERDIR', data)
if not data.getVar("BBPATH", True): if not data.getVar("BBPATH", True):
raise SystemExit("The BBPATH variable is not set") raise SystemExit("The BBPATH variable is not set")
data = bb.parse.handle(os.path.join("conf", "bitbake.conf"), data) data = _parse(os.path.join("conf", "bitbake.conf"), data)
self.configuration.data = data self.configuration.data = data
# Handle any INHERITs and inherit the base class # Handle any INHERITs and inherit the base class
inherits = ["base"] + (bb.data.getVar('INHERIT', self.configuration.data, True ) or "").split() inherits = ["base"] + (bb.data.getVar('INHERIT', self.configuration.data, True ) or "").split()
for inherit in inherits: for inherit in inherits:
self.configuration.data = bb.parse.handle(os.path.join('classes', '%s.bbclass' % inherit), self.configuration.data, True ) self.configuration.data = _parse(os.path.join('classes', '%s.bbclass' % inherit), self.configuration.data, True )
# Nomally we only register event handlers at the end of parsing .bb files # Nomally we only register event handlers at the end of parsing .bb files
# We register any handlers we've found so far here... # We register any handlers we've found so far here...
for var in bb.data.getVar('__BBHANDLERS', self.configuration.data) or []: for var in bb.data.getVar('__BBHANDLERS', self.configuration.data) or []:
bb.event.register(var, bb.data.getVar(var, self.configuration.data)) bb.event.register(var, bb.data.getVar(var, self.configuration.data))
if bb.data.getVar("BB_WORKERCONTEXT", self.configuration.data) is None: if bb.data.getVar("BB_WORKERCONTEXT", self.configuration.data) is None:
bb.fetch.fetcher_init(self.configuration.data) bb.fetch.fetcher_init(self.configuration.data)
bb.codeparser.parser_cache_init(self.configuration.data) bb.codeparser.parser_cache_init(self.configuration.data)
bb.parse.init_parser(data, self.configuration.dump_signatures) bb.parse.init_parser(data, self.configuration.dump_signatures)
bb.event.fire(bb.event.ConfigParsed(), self.configuration.data) bb.event.fire(bb.event.ConfigParsed(), self.configuration.data)
except (IOError, bb.parse.ParseError):
parselog.exception("Error when parsing %s", files)
sys.exit(1)
def handleCollections( self, collections ): def handleCollections( self, collections ):
"""Handle collections""" """Handle collections"""
@@ -899,7 +901,7 @@ class BBCooker:
if not base in self.appendlist: if not base in self.appendlist:
self.appendlist[base] = [] self.appendlist[base] = []
self.appendlist[base].append(f) self.appendlist[base].append(f)
return (bbfiles, masked) return (bbfiles, masked)
def get_file_appends(self, fn): def get_file_appends(self, fn):
@@ -909,7 +911,7 @@ class BBCooker:
""" """
f = os.path.basename(fn) f = os.path.basename(fn)
if f in self.appendlist: if f in self.appendlist:
return self.appendlist[f] return self.appendlist[f]
return [] return []
def pre_serve(self): def pre_serve(self):
+21
View File
@@ -26,6 +26,7 @@ import os, sys
import warnings import warnings
import pickle import pickle
import logging import logging
import atexit
import bb.utils import bb.utils
# This is the pid for which we should generate the event. This is set when # This is the pid for which we should generate the event. This is set when
@@ -74,7 +75,27 @@ def fire_class_handlers(event, d):
h(event) h(event)
del event.data del event.data
ui_queue = []
@atexit.register
def print_ui_queue():
"""If we're exiting before a UI has been spawned, display any queued
LogRecords to the console."""
logger = logging.getLogger("BitBake")
if not _ui_handlers:
console = logging.StreamHandler(sys.stdout)
console.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
logger.handlers = [console]
while ui_queue:
event, d = ui_queue.pop()
if isinstance(event, logging.LogRecord):
logger.handle(event)
def fire_ui_handlers(event, d): def fire_ui_handlers(event, d):
if not _ui_handlers:
# No UI handlers registered yet, queue up the messages
ui_queue.append((event, d))
return
errors = [] errors = []
for h in _ui_handlers: for h in _ui_handlers:
#print "Sending event %s" % event #print "Sending event %s" % event
+2
View File
@@ -174,6 +174,8 @@ class BitBakeServerConnection():
self.server = serverinfo.server self.server = serverinfo.server
self.connection = serverinfo.commands self.connection = serverinfo.commands
self.events = bb.server.none.BBUIEventQueue(self.server) self.events = bb.server.none.BBUIEventQueue(self.server)
for event in bb.event.ui_queue:
self.events.queue_event(event)
def terminate(self): def terminate(self):
try: try:
+2
View File
@@ -243,6 +243,8 @@ class BitBakeServerConnection():
t = BBTransport() t = BBTransport()
self.connection = xmlrpclib.Server("http://%s:%s" % (serverinfo.host, serverinfo.port), transport=t, allow_none=True) self.connection = xmlrpclib.Server("http://%s:%s" % (serverinfo.host, serverinfo.port), transport=t, allow_none=True)
self.events = uievent.BBUIEventQueue(self.connection) self.events = uievent.BBUIEventQueue(self.connection)
for event in bb.event.ui_queue:
self.events.queue_event(event)
def terminate(self): def terminate(self):
# Don't wait for server indefinitely # Don't wait for server indefinitely