##// END OF EJS Templates
fix IPython.embed...
fix IPython.embed without this change, IPython.embed throws the following traceback: File "explete.py", line 9, in dump_inputs IPython.embed() File "/home/pi/code/ipython/IPython/terminal/embed.py", line 287, in embed config = load_default_config() File "/home/pi/code/ipython/IPython/terminal/ipapp.py", line 379, in load_default_config for cf in Application._load_config_files("ipython_config", path=profile_dir): File "/home/pi/code/ipython/IPython/config/application.py", line 527, in _load_config_files log.debug("Loaded config file: %s", loader.full_filename) AttributeError: 'NoneType' object has no attribute 'debug' @Carreau was the last to poke around in this part of the code, so pinging him, just in case

File last commit:

r13888:74d7ea88
r14174:2c0e86ab
Show More
datapub.py
70 lines | 2.3 KiB | text/x-python | PythonLexer
"""Publishing native (typically pickled) objects.
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2012 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
from IPython.config import Configurable
from IPython.kernel.inprocess.socket import SocketABC
from IPython.utils.jsonutil import json_clean
from IPython.utils.traitlets import Instance, Dict, CBytes
from IPython.kernel.zmq.serialize import serialize_object
from IPython.kernel.zmq.session import Session, extract_header
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
class ZMQDataPublisher(Configurable):
topic = topic = CBytes(b'datapub')
session = Instance(Session)
pub_socket = Instance(SocketABC)
parent_header = Dict({})
def set_parent(self, parent):
"""Set the parent for outbound messages."""
self.parent_header = extract_header(parent)
def publish_data(self, data):
"""publish a data_message on the IOPub channel
Parameters
----------
data : dict
The data to be published. Think of it as a namespace.
"""
session = self.session
buffers = serialize_object(data,
buffer_threshold=session.buffer_threshold,
item_threshold=session.item_threshold,
)
content = json_clean(dict(keys=data.keys()))
session.send(self.pub_socket, 'data_message', content=content,
parent=self.parent_header,
buffers=buffers,
ident=self.topic,
)
def publish_data(data):
"""publish a data_message on the IOPub channel
Parameters
----------
data : dict
The data to be published. Think of it as a namespace.
"""
from IPython.kernel.zmq.zmqshell import ZMQInteractiveShell
ZMQInteractiveShell.instance().data_pub.publish_data(data)