diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2016-06-20 14:00:49 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-20 17:23:34 +0100 |
commit | f18055237e6084f90f6221442e3ba021dcc59c50 (patch) | |
tree | 55dabdf089f62b0b457960a4f8775820f5703a5e | |
parent | d3ad8eee850ec2df54aa09fae44cc7e69c12f32a (diff) | |
download | bitbake-f18055237e6084f90f6221442e3ba021dcc59c50.tar.gz |
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@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/cooker.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index b2cf0cda1..2de6b3e0d 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()) |