Show More
@@ -31,12 +31,15 b' class ZMQDisplayHook(object):' | |||||
31 |
|
31 | |||
32 |
|
32 | |||
33 | def _encode_binary(format_dict): |
|
33 | def _encode_binary(format_dict): | |
|
34 | encoded = format_dict.copy() | |||
34 | pngdata = format_dict.get('image/png') |
|
35 | pngdata = format_dict.get('image/png') | |
35 | if pngdata is not None: |
|
36 | if isinstance(pngdata, bytes): | |
36 |
|
|
37 | encoded['image/png'] = encodestring(pngdata).decode('ascii') | |
37 | jpegdata = format_dict.get('image/jpeg') |
|
38 | jpegdata = format_dict.get('image/jpeg') | |
38 | if jpegdata is not None: |
|
39 | if isinstance(jpegdata, bytes): | |
39 |
|
|
40 | encoded['image/jpeg'] = encodestring(jpegdata).decode('ascii') | |
|
41 | ||||
|
42 | return encoded | |||
40 |
|
43 | |||
41 |
|
44 | |||
42 | class ZMQShellDisplayHook(DisplayHook): |
|
45 | class ZMQShellDisplayHook(DisplayHook): | |
@@ -61,8 +64,7 b' class ZMQShellDisplayHook(DisplayHook):' | |||||
61 | self.msg['content']['execution_count'] = self.prompt_count |
|
64 | self.msg['content']['execution_count'] = self.prompt_count | |
62 |
|
65 | |||
63 | def write_format_data(self, format_dict): |
|
66 | def write_format_data(self, format_dict): | |
64 | _encode_binary(format_dict) |
|
67 | self.msg['content']['data'] = _encode_binary(format_dict) | |
65 | self.msg['content']['data'] = format_dict |
|
|||
66 |
|
68 | |||
67 | def finish_displayhook(self): |
|
69 | def finish_displayhook(self): | |
68 | """Finish up all displayhook activities.""" |
|
70 | """Finish up all displayhook activities.""" |
@@ -77,8 +77,7 b' class ZMQDisplayPublisher(DisplayPublisher):' | |||||
77 | self._validate_data(source, data, metadata) |
|
77 | self._validate_data(source, data, metadata) | |
78 | content = {} |
|
78 | content = {} | |
79 | content['source'] = source |
|
79 | content['source'] = source | |
80 | _encode_binary(data) |
|
80 | content['data'] = _encode_binary(data) | |
81 | content['data'] = data |
|
|||
82 | content['metadata'] = metadata |
|
81 | content['metadata'] = metadata | |
83 | self.session.send( |
|
82 | self.session.send( | |
84 | self.pub_socket, u'display_data', json_clean(content), |
|
83 | self.pub_socket, u'display_data', json_clean(content), |
General Comments 0
You need to be logged in to leave comments.
Login now