[oe-commits] [bitbake] 03/06: cooker: encode event objects to base64
git at git.openembedded.org
git at git.openembedded.org
Mon Jun 20 16:24:59 UTC 2016
rpurdie pushed a commit to branch master
in repository bitbake.
commit f18055237e6084f90f6221442e3ba021dcc59c50
Author: Ed Bartosh <ed.bartosh at linux.intel.com>
AuthorDate: Mon Jun 20 14:00:49 2016 +0300
cooker: encode event objects to base64
pickle converts python objects into the binary form that can't be
decoded to text and therefore can't be converted to JSON format.
Attempt to convert event objects raises this error:
TypeError:
b'\x80\x03cbb.runqueue\nrunQueueTaskSkipped\nq\x00)...
is not JSON serializable
Encoded pickled event objects to base64 to be able to convert data
structure to JSON.
[YOCTO #9803]
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
lib/bb/cooker.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index b2cf0cd..2de6b3e 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -44,6 +44,7 @@ import prserv.serv
import pyinotify
import json
import pickle
+import codecs
logger = logging.getLogger("BitBake")
collectlog = logging.getLogger("BitBake.Collection")
@@ -143,7 +144,9 @@ class EventLogWriteHandler:
def write_event(self, event):
with open(self.eventfile, "a") as f:
try:
- f.write("%s\n" % json.dumps({"class":event.__module__ + "." + event.__class__.__name__, "vars":json.dumps(pickle.dumps(event)) }))
+ str_event = codecs.encode(pickle.dumps(event), 'base64').decode('utf-8')
+ f.write("%s\n" % json.dumps({"class": event.__module__ + "." + event.__class__.__name__,
+ "vars": str_event}))
except Exception as e:
import traceback
print(e, traceback.format_exc())
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list