From 22a271aaa99daeb6b29c42c2c1dc670bf204310e Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 19 Jan 2010 14:48:19 +0000 Subject: bitbake-dev: Sync with upstream Signed-off-by: Richard Purdie --- bitbake-dev/lib/bb/ui/crumbs/runningbuild.py | 28 ++++++------ bitbake-dev/lib/bb/ui/depexp.py | 20 ++++----- bitbake-dev/lib/bb/ui/knotty.py | 66 ++++++++++++++-------------- bitbake-dev/lib/bb/ui/ncurses.py | 44 +++++++++---------- bitbake-dev/lib/bb/ui/uievent.py | 24 +++++----- bitbake-dev/lib/bb/ui/uihelper.py | 22 +++++----- 6 files changed, 101 insertions(+), 103 deletions(-) (limited to 'bitbake-dev/lib/bb/ui') diff --git a/bitbake-dev/lib/bb/ui/crumbs/runningbuild.py b/bitbake-dev/lib/bb/ui/crumbs/runningbuild.py index 34f65d2396..401559255b 100644 --- a/bitbake-dev/lib/bb/ui/crumbs/runningbuild.py +++ b/bitbake-dev/lib/bb/ui/crumbs/runningbuild.py @@ -61,36 +61,36 @@ class RunningBuild (gobject.GObject): # If we have a pid attached to this message/event try and get the # (package, task) pair for it. If we get that then get the parent iter # for the message. - if event[1].has_key ('pid'): - pid = event[1]['pid'] + if hassattr(event, 'pid'): + pid = event.pid if self.pids_to_task.has_key(pid): (package, task) = self.pids_to_task[pid] parent = self.tasks_to_iter[(package, task)] - if event[0].startswith('bb.msg.Msg'): + if isinstance(event, bb.msg.Msg): # Set a pretty icon for the message based on it's type. - if (event[0].startswith ('bb.msg.MsgWarn')): + if isinstance(event, bb.msg.MsgWarn): icon = "dialog-warning" - elif (event[0].startswith ('bb.msg.MsgErr')): + elif isinstance(event, bb.msg.MsgErr): icon = "dialog-error" else: icon = None # Ignore the "Running task i of n .." messages - if (event[1]['_message'].startswith ("Running task")): + if (event._message.startswith ("Running task")): return # Add the message to the tree either at the top level if parent is # None otherwise as a descendent of a task. self.model.append (parent, - (event[0].split()[-1], # e.g. MsgWarn, MsgError + (event.__name__.split()[-1], # e.g. MsgWarn, MsgError package, task, - event[1]['_message'], + event._message, icon, False)) - elif event[0].startswith('bb.build.TaskStarted'): - (package, task) = (event[1]['_package'], event[1]['_task']) + elif isinstance(event, bb.build.TaskStarted): + (package, task) = (event._package, event._task) # Save out this PID. self.pids_to_task[pid] = (package,task) @@ -128,9 +128,9 @@ class RunningBuild (gobject.GObject): # Mark this task as active. self.model.set(i, self.model.COL_ICON, "gtk-execute") - elif event[0].startswith('bb.build.Task'): + elif isinstance(event, bb.build.Task): - if event[0].startswith('bb.build.TaskFailed'): + if isinstance(event, bb.build.TaskFailed): # Mark the task as failed i = self.tasks_to_iter[(package, task)] self.model.set(i, self.model.COL_ICON, "dialog-error") @@ -153,8 +153,8 @@ class RunningBuild (gobject.GObject): del self.tasks_to_iter[(package, task)] del self.pids_to_task[pid] - elif event[0].startswith('bb.event.BuildCompleted'): - failures = int (event[1]['_failures']) + elif isinstance(event, bb.event.BuildCompleted): + failures = int (event._failures) # Emit the appropriate signal depending on the number of failures if (failures > 1): diff --git a/bitbake-dev/lib/bb/ui/depexp.py b/bitbake-dev/lib/bb/ui/depexp.py index 0c559c7976..cfa5b6564e 100644 --- a/bitbake-dev/lib/bb/ui/depexp.py +++ b/bitbake-dev/lib/bb/ui/depexp.py @@ -229,12 +229,12 @@ def init(server, eventHandler): if event is None: continue - if event[0].startswith('bb.event.ParseProgress'): - x = event[1]['sofar'] - y = event[1]['total'] + if isinstance(event, bb.event.ParseProgress): + x = event.sofar + y = event.total if x == y: print("\nParsing finished. %d cached, %d parsed, %d skipped, %d masked, %d errors." - % ( event[1]['cached'], event[1]['parsed'], event[1]['skipped'], event[1]['masked'], event[1]['errors'])) + % ( event.cached, event.parsed, event.skipped, event.masked, event.errors)) pbar.hide() gtk.gdk.threads_enter() pbar.progress.set_fraction(float(x)/float(y)) @@ -242,17 +242,17 @@ def init(server, eventHandler): gtk.gdk.threads_leave() continue - if event[0] == "bb.event.DepTreeGenerated": + if isinstance(event, bb.event.DepTreeGenerated): gtk.gdk.threads_enter() - parse(event[1]['_depgraph'], dep.pkg_model, dep.depends_model) + parse(event._depgraph, dep.pkg_model, dep.depends_model) gtk.gdk.threads_leave() - if event[0] == 'bb.command.CookerCommandCompleted': + if isinstance(event, bb.command.CookerCommandCompleted): continue - if event[0] == 'bb.command.CookerCommandFailed': - print "Command execution failed: %s" % event[1]['error'] + if isinstance(event, bb.command.CookerCommandFailed): + print "Command execution failed: %s" % event.error break - if event[0] == 'bb.cooker.CookerExit': + if isinstance(event, bb.cooker.CookerExit): break continue diff --git a/bitbake-dev/lib/bb/ui/knotty.py b/bitbake-dev/lib/bb/ui/knotty.py index 8a2afeeb6d..6baed836a1 100644 --- a/bitbake-dev/lib/bb/ui/knotty.py +++ b/bitbake-dev/lib/bb/ui/knotty.py @@ -53,29 +53,29 @@ def init(server, eventHandler): if event is None: continue #print event - if event[0].startswith('bb.msg.MsgPlain'): - print event[1]['_message'] + if isinstance(event, bb.msg.MsgPlain): + print event._message continue - if event[0].startswith('bb.msg.MsgDebug'): - print 'DEBUG: ' + event[1]['_message'] + if isinstance(event, bb.msg.MsgDebug): + print 'DEBUG: ' + event._message continue - if event[0].startswith('bb.msg.MsgNote'): - print 'NOTE: ' + event[1]['_message'] + if isinstance(event, bb.msg.MsgNote): + print 'NOTE: ' + event._message continue - if event[0].startswith('bb.msg.MsgWarn'): - print 'WARNING: ' + event[1]['_message'] + if isinstance(event, bb.msg.MsgWarn): + print 'WARNING: ' + event._message continue - if event[0].startswith('bb.msg.MsgError'): + if isinstance(event, bb.msg.MsgError): return_value = 1 - print 'ERROR: ' + event[1]['_message'] + print 'ERROR: ' + event._message continue - if event[0].startswith('bb.msg.MsgFatal'): + if isinstance(event, bb.msg.MsgFatal): return_value = 1 - print 'FATAL: ' + event[1]['_message'] + print 'FATAL: ' + event._message break - if event[0].startswith('bb.build.TaskFailed'): + if isinstance(event, bb.build.TaskFailed): return_value = 1 - logfile = event[1]['logfile'] + logfile = event.logfile if logfile: print "ERROR: Logfile of failure stored in %s." % logfile if 1 or includelogs: @@ -97,12 +97,12 @@ def init(server, eventHandler): if lines: for line in lines: print line - if event[0].startswith('bb.build.Task'): - print "NOTE: %s" % event[1]['_message'] + if isinstance(event, bb.build.TaskBase): + print "NOTE: %s" % event._message continue - if event[0].startswith('bb.event.ParseProgress'): - x = event[1]['sofar'] - y = event[1]['total'] + if isinstance(event, bb.event.ParseProgress): + x = event.sofar + y = event.total if os.isatty(sys.stdout.fileno()): sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) ) sys.stdout.flush() @@ -115,35 +115,35 @@ def init(server, eventHandler): sys.stdout.flush() if x == y: print("\nParsing finished. %d cached, %d parsed, %d skipped, %d masked, %d errors." - % ( event[1]['cached'], event[1]['parsed'], event[1]['skipped'], event[1]['masked'], event[1]['errors'])) + % ( event.cached, event.parsed, event.skipped, event.masked, event.errors)) continue - if event[0] == 'bb.command.CookerCommandCompleted': + if isinstance(event, bb.command.CookerCommandCompleted): break - if event[0] == 'bb.command.CookerCommandSetExitCode': - return_value = event[1]['exitcode'] + if isinstance(event, bb.command.CookerCommandSetExitCode): + return_value = event.exitcode continue - if event[0] == 'bb.command.CookerCommandFailed': + if isinstance(event, bb.command.CookerCommandFailed): return_value = 1 - print "Command execution failed: %s" % event[1]['error'] + print "Command execution failed: %s" % event.error break - if event[0] == 'bb.cooker.CookerExit': + if isinstance(event, bb.cooker.CookerExit): break # ignore - if event[0].startswith('bb.event.BuildStarted'): + if isinstance(event, bb.event.BuildStarted): continue - if event[0].startswith('bb.event.BuildCompleted'): + if isinstance(event, bb.event.BuildCompleted): continue - if event[0].startswith('bb.event.MultipleProviders'): + if isinstance(event, bb.event.MultipleProviders): continue - if event[0].startswith('bb.runqueue.runQueue'): + if isinstance(event, bb.runqueue.runQueueEvent): continue - if event[0].startswith('bb.event.StampUpdate'): + if isinstance(event, bb.event.StampUpdate): continue - if event[0].startswith('bb.event.ConfigParsed'): + if isinstance(event, bb.event.ConfigParsed): continue - if event[0].startswith('bb.event.RecipeParsed'): + if isinstance(event, bb.event.RecipeParsed): continue print "Unknown Event: %s" % event diff --git a/bitbake-dev/lib/bb/ui/ncurses.py b/bitbake-dev/lib/bb/ui/ncurses.py index 2cd7e8e6e7..14310dc124 100644 --- a/bitbake-dev/lib/bb/ui/ncurses.py +++ b/bitbake-dev/lib/bb/ui/ncurses.py @@ -246,29 +246,29 @@ class NCursesUI: continue helper.eventHandler(event) #mw.appendText("%s\n" % event[0]) - if event[0].startswith('bb.build.Task'): - mw.appendText("NOTE: %s\n" % event[1]['_message']) - if event[0].startswith('bb.msg.MsgDebug'): - mw.appendText('DEBUG: ' + event[1]['_message'] + '\n') - if event[0].startswith('bb.msg.MsgNote'): - mw.appendText('NOTE: ' + event[1]['_message'] + '\n') - if event[0].startswith('bb.msg.MsgWarn'): - mw.appendText('WARNING: ' + event[1]['_message'] + '\n') - if event[0].startswith('bb.msg.MsgError'): - mw.appendText('ERROR: ' + event[1]['_message'] + '\n') - if event[0].startswith('bb.msg.MsgFatal'): - mw.appendText('FATAL: ' + event[1]['_message'] + '\n') - if event[0].startswith('bb.event.ParseProgress'): - x = event[1]['sofar'] - y = event[1]['total'] + if isinstance(event, bb.build.Task): + mw.appendText("NOTE: %s\n" % event._message) + if isinstance(event, bb.msg.MsgDebug): + mw.appendText('DEBUG: ' + event._message + '\n') + if isinstance(event, bb.msg.MsgNote): + mw.appendText('NOTE: ' + event._message + '\n') + if isinstance(event, bb.msg.MsgWarn): + mw.appendText('WARNING: ' + event._message + '\n') + if isinstance(event, bb.msg.MsgError): + mw.appendText('ERROR: ' + event._message + '\n') + if isinstance(event, bb.msg.MsgFatal): + mw.appendText('FATAL: ' + event._message + '\n') + if isinstance(event, bb.event.ParseProgress): + x = event.sofar + y = event.total if x == y: mw.setStatus("Idle") mw.appendText("Parsing finished. %d cached, %d parsed, %d skipped, %d masked." - % ( event[1]['cached'], event[1]['parsed'], event[1]['skipped'], event[1]['masked'] )) + % ( event.cached, event.parsed, event.skipped, event.masked )) else: mw.setStatus("Parsing: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) ) -# if event[0].startswith('bb.build.TaskFailed'): -# if event[1]['logfile']: +# if isinstance(event, bb.build.TaskFailed): +# if event.logfile: # if data.getVar("BBINCLUDELOGS", d): # bb.msg.error(bb.msg.domain.Build, "log data follows (%s)" % logfile) # number_of_lines = data.getVar("BBINCLUDELOGS_LINES", d) @@ -286,13 +286,13 @@ class NCursesUI: # else: # bb.msg.error(bb.msg.domain.Build, "see log in %s" % logfile) - if event[0] == 'bb.command.CookerCommandCompleted': + if isinstance(event, bb.command.CookerCommandCompleted): exitflag = True - if event[0] == 'bb.command.CookerCommandFailed': - mw.appendText("Command execution failed: %s" % event[1]['error']) + if isinstance(event, bb.command.CookerCommandFailed): + mw.appendText("Command execution failed: %s" % event.error) time.sleep(2) exitflag = True - if event[0] == 'bb.cooker.CookerExit': + if isinstance(event, bb.cooker.CookerExit): exitflag = True if helper.needUpdate: diff --git a/bitbake-dev/lib/bb/ui/uievent.py b/bitbake-dev/lib/bb/ui/uievent.py index 23fdd0f961..36302f4da7 100644 --- a/bitbake-dev/lib/bb/ui/uievent.py +++ b/bitbake-dev/lib/bb/ui/uievent.py @@ -24,7 +24,7 @@ server and queue them for the UI to process. This process must be used to avoid client/server deadlocks. """ -import socket, threading +import socket, threading, pickle from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler class BBUIEventQueue: @@ -37,8 +37,8 @@ class BBUIEventQueue: self.BBServer = BBServer self.t = threading.Thread() - self.t.setDaemon(True) - self.t.run = self.startCallbackHandler + self.t.setDaemon(True) + self.t.run = self.startCallbackHandler self.t.start() def getEvent(self): @@ -55,7 +55,6 @@ class BBUIEventQueue: self.eventQueueNotify.clear() self.eventQueueLock.release() - return item def waitEvent(self, delay): @@ -63,16 +62,15 @@ class BBUIEventQueue: return self.getEvent() def queue_event(self, event): - self.eventQueueLock.acquire() - self.eventQueue.append(event) + self.eventQueue.append(pickle.loads(event)) self.eventQueueNotify.set() self.eventQueueLock.release() def startCallbackHandler(self): server = UIXMLRPCServer() - self.host, self.port = server.socket.getsockname() + self.host, self.port = server.socket.getsockname() server.register_function( self.system_quit, "event.quit" ) server.register_function( self.queue_event, "event.send" ) @@ -85,7 +83,7 @@ class BBUIEventQueue: server.handle_request() server.server_close() - def system_quit( self ): + def system_quit( self ): """ Shut down the callback thread """ @@ -97,11 +95,11 @@ class BBUIEventQueue: class UIXMLRPCServer (SimpleXMLRPCServer): - def __init__( self, interface = ("localhost", 0) ): + def __init__( self, interface = ("localhost", 0) ): self.quit = False - SimpleXMLRPCServer.__init__( self, - interface, - requestHandler=SimpleXMLRPCRequestHandler, + SimpleXMLRPCServer.__init__( self, + interface, + requestHandler=SimpleXMLRPCRequestHandler, logRequests=False, allow_none=True) def get_request(self): @@ -123,5 +121,5 @@ class UIXMLRPCServer (SimpleXMLRPCServer): if request is None: return SimpleXMLRPCServer.process_request(self, request, client_address) - + diff --git a/bitbake-dev/lib/bb/ui/uihelper.py b/bitbake-dev/lib/bb/ui/uihelper.py index 246844c9d2..151ffc5854 100644 --- a/bitbake-dev/lib/bb/ui/uihelper.py +++ b/bitbake-dev/lib/bb/ui/uihelper.py @@ -24,25 +24,25 @@ class BBUIHelper: self.failed_tasks = {} def eventHandler(self, event): - if event[0].startswith('bb.build.TaskStarted'): - self.running_tasks["%s %s\n" % (event[1]['_package'], event[1]['_task'])] = "" + if isinstance(event, bb.build.TaskStarted): + self.running_tasks["%s %s\n" % (event._package, event._task)] = "" self.needUpdate = True - if event[0].startswith('bb.build.TaskSucceeded'): - del self.running_tasks["%s %s\n" % (event[1]['_package'], event[1]['_task'])] + if isinstance(event, bb.build.TaskSucceeded): + del self.running_tasks["%s %s\n" % (event._package, event._task)] self.needUpdate = True - if event[0].startswith('bb.build.TaskFailed'): - del self.running_tasks["%s %s\n" % (event[1]['_package'], event[1]['_task'])] - self.failed_tasks["%s %s\n" % (event[1]['_package'], event[1]['_task'])] = "" + if isinstance(event, bb.build.TaskFailed): + del self.running_tasks["%s %s\n" % (event._package, event._task)] + self.failed_tasks["%s %s\n" % (event._package, event._task)] = "" self.needUpdate = True # Add runqueue event handling - #if event[0].startswith('bb.runqueue.runQueueTaskCompleted'): + #if isinstance(event, bb.runqueue.runQueueTaskCompleted): # a = 1 - #if event[0].startswith('bb.runqueue.runQueueTaskStarted'): + #if isinstance(event, bb.runqueue.runQueueTaskStarted): # a = 1 - #if event[0].startswith('bb.runqueue.runQueueTaskFailed'): + #if isinstance(event, bb.runqueue.runQueueTaskFailed): # a = 1 - #if event[0].startswith('bb.runqueue.runQueueExitWait'): + #if isinstance(event, bb.runqueue.runQueueExitWait): # a = 1 def getTasks(self): -- cgit v1.2.3