summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-01-19 09:56:25 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2010-01-19 09:56:25 +0000
commit2778a69e31715ecb7a2fafc986d82d6f7df3074b (patch)
treee7c1216a05c0c4089f981ae03309f370d29db850 /lib
parent45997fbe2a4630952f9632fdb44a067d3c3aafca (diff)
downloadbitbake-2778a69e31715ecb7a2fafc986d82d6f7df3074b.tar.gz
event.py: Convert to using pickle for events and isinstance in knotty UI handler
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/bb/event.py7
-rw-r--r--lib/bb/server/none.py6
-rw-r--r--lib/bb/ui/knotty.py66
-rw-r--r--lib/bb/ui/uievent.py6
4 files changed, 43 insertions, 42 deletions
diff --git a/lib/bb/event.py b/lib/bb/event.py
index 14384159d..8b4222bfc 100644
--- a/lib/bb/event.py
+++ b/lib/bb/event.py
@@ -24,6 +24,7 @@ BitBake build tools.
import os, re
import bb.utils
+import pickle
# This is the pid for which we should generate the event. This is set when
# the runqueue forks off.
@@ -62,9 +63,11 @@ def fire(event, d):
errors = []
for h in _ui_handlers:
#print "Sending event %s" % event
- classid = "%s.%s" % (event.__class__.__module__, event.__class__.__name__)
try:
- _ui_handlers[h].event.send((classid, event))
+ # We use pickle here since it better handles object instances
+ # which xmlrpc's marshaller does not. Events *must* be serializable
+ # by pickle.
+ _ui_handlers[h].event.send((pickle.dumps(event)))
except:
errors.append(h)
for h in errors:
diff --git a/lib/bb/server/none.py b/lib/bb/server/none.py
index ed608fc04..ebda11158 100644
--- a/lib/bb/server/none.py
+++ b/lib/bb/server/none.py
@@ -35,6 +35,7 @@ import time
import bb
from bb.ui import uievent
import xmlrpclib
+import pickle
DEBUG = False
@@ -58,7 +59,7 @@ class BitBakeServerCommands():
Trigger the server to quit
"""
self.server.server_exit()
- print "Server (cooker) exitting"
+ #print "Server (cooker) exitting"
return
def ping(self):
@@ -75,8 +76,7 @@ class BBUIEventQueue:
self.parent = parent
@staticmethod
def send(event):
- event = xmlrpclib.loads(xmlrpclib.dumps(event, allow_none=True))
- bb.server.none.eventQueue.append(event[0])
+ bb.server.none.eventQueue.append(pickle.loads(event))
@staticmethod
def quit():
return
diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index 8a2afeeb6..6baed836a 100644
--- a/lib/bb/ui/knotty.py
+++ b/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/lib/bb/ui/uievent.py b/lib/bb/ui/uievent.py
index 476eb4c59..36302f4da 100644
--- a/lib/bb/ui/uievent.py
+++ b/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:
@@ -55,7 +55,6 @@ class BBUIEventQueue:
self.eventQueueNotify.clear()
self.eventQueueLock.release()
-
return item
def waitEvent(self, delay):
@@ -63,9 +62,8 @@ 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()