##// END OF EJS Templates
Merge pull request #7128 from minrk/more-v-less-m...
Merge pull request #7128 from minrk/more-v-less-m A little more V, a little less M in the text editor

File last commit:

r19250:bdae5330
r19383:aacc2374 merge
Show More
zmqshell.py
488 lines | 17.9 KiB | text/x-python | PythonLexer
Fernando Perez
Ensure that an absolute path is encoded in %edit payload.
r2889 """A ZMQ-based subclass of InteractiveShell.
This code is meant to ease the refactoring of the base InteractiveShell into
something with a cleaner architecture for 2-process use, without actually
breaking InteractiveShell itself. So we're doing something a bit ugly, where
we subclass and override what we want to fix. Once this is working well, we
can go back to the base class and refactor the code for a cleaner inheritance
implementation that doesn't rely on so much monkeypatching.
But this lets us maintain a fully working IPython as we develop the new
machinery. This should thus be thought of as scaffolding.
"""
MinRK
pyout -> execute_result...
r16568
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.
Fernando Perez
Prevent !cmd to try to run backgrounded (cmd &) processes.
r2891 from __future__ import print_function
Fernando Perez
Ensure that an absolute path is encoded in %edit payload.
r2889 import os
MinRK
add %qtconsole magic for conveniently launching second console
r4965 import sys
MinRK
fixup shutdown/exit now that we use IOLoop...
r6799 import time
Brian Granger
Initial support in ipkernel for proper displayhook handling.
r2786
MinRK
fixup shutdown/exit now that we use IOLoop...
r6799 from zmq.eventloop import ioloop
Brian Granger
Initial support in ipkernel for proper displayhook handling.
r2786 from IPython.core.interactiveshell import (
InteractiveShell, InteractiveShellABC
)
MinRK
update zmq shell magics...
r7076 from IPython.core import page
Thomas Kluyver
Subclass exit autocallable for two process shells, with argument to keep kernel alive.
r3724 from IPython.core.autocall import ZMQExitAutocall
Brian Granger
Mostly final version of display data....
r3277 from IPython.core.displaypub import DisplayPublisher
Bradley M. Froehle
Better error messages for common magic commands....
r8278 from IPython.core.error import UsageError
MinRK
update zmq shell magics...
r7076 from IPython.core.magics import MacroToEdit, CodeMagics
from IPython.core.magic import magics_class, line_magic, Magics
Fernando Perez
Add experimental support for cell-based execution....
r2967 from IPython.core.payloadpage import install_payload_page
MinRK
add kernel banner to terminal and qt frontends
r16583 from IPython.core.usage import default_gui_banner
MinRK
add %autosave magic from autosave extension
r10510 from IPython.display import display, Javascript
MinRK
move IPython.inprocess to IPython.kernel.inprocess
r9375 from IPython.kernel.inprocess.socket import SocketABC
MinRK
move utils.kernel (formerly entry_point and lib.kernel) to kernel.util
r9353 from IPython.kernel import (
MinRK
add IPython.lib.kernel...
r4970 get_connection_file, get_connection_info, connect_qtconsole
)
MinRK
skip magic_edit doctest in zmqshell...
r6565 from IPython.testing.skipdoctest import skip_doctest
Thomas Kluyver
Remove unused imports in IPython.kernel
r11130 from IPython.utils import openpy
MinRK
move _encode_binary to jsonutil.encode_images...
r7737 from IPython.utils.jsonutil import json_clean, encode_images
MinRK
add IPython.lib.kernel...
r4970 from IPython.utils.process import arg_split
Thomas Kluyver
Protect zmqshell against non-unicode safe exceptions....
r7319 from IPython.utils import py3compat
Thomas Kluyver
Replace references to unicode and basestring
r13353 from IPython.utils.py3compat import unicode_type
MinRK
fixup kernel Any trait
r13201 from IPython.utils.traitlets import Instance, Type, Dict, CBool, CBytes, Any
Thomas Kluyver
Remove unused imports in IPython.kernel
r11130 from IPython.utils.warn import error
MinRK
mv IPython.zmq to IPython.kernel.zmq
r9372 from IPython.kernel.zmq.displayhook import ZMQShellDisplayHook
from IPython.kernel.zmq.datapub import ZMQDataPublisher
from IPython.kernel.zmq.session import extract_header
Thomas Kluyver
Use explicit relative imports...
r13347 from .session import Session
Brian Granger
Paging using payloads now works.
r2830
Fernando Perez
Ensure that an absolute path is encoded in %edit payload.
r2889 #-----------------------------------------------------------------------------
# Functions and classes
#-----------------------------------------------------------------------------
Brian Granger
Initial support in ipkernel for proper displayhook handling.
r2786
Brian Granger
Mostly final version of display data....
r3277 class ZMQDisplayPublisher(DisplayPublisher):
Brian Granger
Display system is fully working now....
r3278 """A display publisher that publishes data using a ZeroMQ PUB socket."""
Brian Granger
Mostly final version of display data....
r3277
session = Instance(Session)
epatters
Add abstract base class (ABC) for sockets used in kernel.
r8418 pub_socket = Instance(SocketABC)
Brian Granger
Mostly final version of display data....
r3277 parent_header = Dict({})
MinRK
set some topics on IOPub messages...
r11697 topic = CBytes(b'display_data')
Brian Granger
Mostly final version of display data....
r3277
def set_parent(self, parent):
"""Set the parent for outbound messages."""
self.parent_header = extract_header(parent)
MinRK
display_pub implies stdout/err flush...
r6316
def _flush_streams(self):
"""flush IO Streams prior to display"""
sys.stdout.flush()
sys.stderr.flush()
Brian Granger
Mostly final version of display data....
r3277
MinRK
remove `source` key from display_data
r16585 def publish(self, data, metadata=None, source=None):
MinRK
display_pub implies stdout/err flush...
r6316 self._flush_streams()
Brian Granger
Mostly final version of display data....
r3277 if metadata is None:
metadata = {}
MinRK
remove `source` key from display_data
r16585 self._validate_data(data, metadata)
Brian Granger
Using session.send in DisplayPublisher now.
r3287 content = {}
MinRK
move _encode_binary to jsonutil.encode_images...
r7737 content['data'] = encode_images(data)
Brian Granger
Using session.send in DisplayPublisher now.
r3287 content['metadata'] = metadata
self.session.send(
MinRK
json_clean zmqshell replies...
r4784 self.pub_socket, u'display_data', json_clean(content),
MinRK
add topic to display publisher, and fix set_parent for apply_requests
r6834 parent=self.parent_header, ident=self.topic,
Brian Granger
Using session.send in DisplayPublisher now.
r3287 )
Brian Granger
Mostly final version of display data....
r3277
Jonathan Frederic
Added wait flag to clear_output.
r12592 def clear_output(self, wait=False):
content = dict(wait=wait)
MinRK
clear_output implies '\r' for terminal frontends
r6422 self._flush_streams()
Brian Granger
Adding clear_output to kernel and HTML notebook.
r5080 self.session.send(
MinRK
add channel-selection to clear_output...
r5085 self.pub_socket, u'clear_output', content,
MinRK
add topic to display publisher, and fix set_parent for apply_requests
r6834 parent=self.parent_header, ident=self.topic,
Brian Granger
Adding clear_output to kernel and HTML notebook.
r5080 )
Brian Granger
Mostly final version of display data....
r3277
MinRK
update zmq shell magics...
r7076 @magics_class
class KernelMagics(Magics):
Fernando Perez
Move terminal-only magics to the terminal class....
r2975 #------------------------------------------------------------------------
# Magic overrides
#------------------------------------------------------------------------
# Once the base class stops inheriting from magic, this code needs to be
# moved into a separate machinery as well. For now, at least isolate here
# the magics which this class needs to implement differently from the base
# class, or that are unique to it.
MinRK
update zmq shell magics...
r7076
_find_edit_target = CodeMagics._find_edit_target
Fernando Perez
Implement %doctest_mode magic in zmqshell with payload....
r2960
MinRK
skip magic_edit doctest in zmqshell...
r6565 @skip_doctest
MinRK
update zmq shell magics...
r7076 @line_magic
def edit(self, parameter_s='', last_call=['','']):
Brian Granger
Started %edit magic.
r2826 """Bring up an editor and execute the resulting code.
Usage:
%edit [options] [args]
Thomas Kluyver
Update docstrings for magic_edit (both the terminal version and the GUI version)
r4714 %edit runs an external text editor. You will need to set the command for
this editor via the ``TerminalInteractiveShell.editor`` option in your
configuration file before it will work.
Brian Granger
Started %edit magic.
r2826
This command allows you to conveniently edit multi-line code right in
your IPython session.
Bernardo B. Marques
remove all trailling spaces
r4872
Brian Granger
Started %edit magic.
r2826 If called without arguments, %edit opens up an empty editor with a
temporary file and will execute the contents of this file when you
close it (don't forget to save it!).
Options:
Thomas Kluyver
More fixes to doc formatting
r13598 -n <number>
Open the editor at a specified line number. By default, the IPython
editor hook uses the unix syntax 'editor +N filename', but you can
configure this by providing your own modified hook if your favorite
editor supports line-number specifications with a different syntax.
-p
Call the editor with the same data as the previous time it was used,
regardless of how long ago (in your current session) it was.
-r
Use 'raw' input. This option only applies to input taken from the
user's history. By default, the 'processed' history is used, so that
magics are loaded in their transformed version to valid Python. If
this option is given, the raw input as typed as the command line is
used instead. When you exit the editor, it will be executed by
IPython's own processor.
Brian Granger
Started %edit magic.
r2826 Arguments:
If arguments are given, the following possibilites exist:
- The arguments are numbers or pairs of colon-separated numbers (like
Thomas Kluyver
More fixes to doc formatting
r13598 1 4:8 9). These are interpreted as lines of previous input to be
loaded into the editor. The syntax is the same of the %macro command.
Brian Granger
Started %edit magic.
r2826
- If the argument doesn't start with a number, it is evaluated as a
Thomas Kluyver
More fixes to doc formatting
r13598 variable and its contents loaded into the editor. You can thus edit
any string which contains python code (including the result of
previous edits).
Brian Granger
Started %edit magic.
r2826
- If the argument is the name of an object (other than a string),
Thomas Kluyver
More fixes to doc formatting
r13598 IPython will try to locate the file where it was defined and open the
editor at the point where it is defined. You can use ``%edit function``
to load an editor exactly at the point where 'function' is defined,
edit it and have the file be executed automatically.
Brian Granger
Started %edit magic.
r2826
Thomas Kluyver
More fixes to doc formatting
r13598 If the object is a macro (see %macro for details), this opens up your
specified editor with a temporary file containing the macro's data.
Upon exit, the macro is reloaded with the contents of the file.
Brian Granger
Started %edit magic.
r2826
Thomas Kluyver
More fixes to doc formatting
r13598 Note: opening at an exact line is only supported under Unix, and some
editors (like kedit and gedit up to Gnome 2.8) do not understand the
'+NUMBER' parameter necessary for this feature. Good editors like
(X)Emacs, vi, jed, pico and joe all do.
Brian Granger
Started %edit magic.
r2826
- If the argument is not found as a variable, IPython will look for a
Thomas Kluyver
More fixes to doc formatting
r13598 file with that name (adding .py if necessary) and load it into the
editor. It will execute its contents with execfile() when you exit,
loading any code in the file into your interactive namespace.
Brian Granger
Started %edit magic.
r2826
Thomas Kluyver
Correct %edit docstring for ZMQ shell
r13599 Unlike in the terminal, this is designed to use a GUI editor, and we do
not know when it has closed. So the file you edit will not be
automatically executed or printed.
Brian Granger
Started %edit magic.
r2826
Note that %edit is also available through the alias %ed.
Thomas Kluyver
Update docstrings for magic_edit (both the terminal version and the GUI version)
r4714 """
Bernardo B. Marques
remove all trailling spaces
r4872
Thomas Kluyver
Fix up magic_edit functions so they work again.
r3891 opts,args = self.parse_options(parameter_s,'prn:')
Bernardo B. Marques
remove all trailling spaces
r4872
Brian Granger
Started %edit magic.
r2826 try:
MinRK
update zmq shell magics...
r7076 filename, lineno, _ = CodeMagics._find_edit_target(self.shell, args, opts, last_call)
Thomas Kluyver
Refactor magic_edit code somewhat.
r3890 except MacroToEdit as e:
# TODO: Implement macro editing over 2 processes.
Thomas Kluyver
Fix up magic_edit functions so they work again.
r3891 print("Macro editing not yet implemented in 2-process model.")
Thomas Kluyver
Refactor magic_edit code somewhat.
r3890 return
Brian Granger
Started %edit magic.
r2826
Fernando Perez
Ensure that an absolute path is encoded in %edit payload.
r2889 # Make sure we send to the client an absolute path, in case the working
# directory of client and kernel don't match
filename = os.path.abspath(filename)
Brian Granger
Started %edit magic.
r2826 payload = {
MinRK
update payload source...
r11839 'source' : 'edit_magic',
Brian Granger
Started %edit magic.
r2826 'filename' : filename,
'line_number' : lineno
}
MinRK
update zmq shell magics...
r7076 self.shell.payload_manager.write_payload(payload)
Brian Granger
Started %edit magic.
r2826
Fernando Perez
Add init_environment(), %less, %more, %man and %clear/%cls, in zmq shell....
r3005 # A few magics that are adapted to the specifics of using pexpect and a
# remote terminal
MinRK
update zmq shell magics...
r7076 @line_magic
def clear(self, arg_s):
Fernando Perez
Add init_environment(), %less, %more, %man and %clear/%cls, in zmq shell....
r3005 """Clear the terminal."""
if os.name == 'posix':
self.shell.system("clear")
else:
self.shell.system("cls")
if os.name == 'nt':
# This is the usual name in windows
MinRK
update zmq shell magics...
r7076 cls = line_magic('cls')(clear)
Fernando Perez
Add init_environment(), %less, %more, %man and %clear/%cls, in zmq shell....
r3005
# Terminal pagers won't work over pexpect, but we do have our own pager
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
update zmq shell magics...
r7076 @line_magic
def less(self, arg_s):
Fernando Perez
Add init_environment(), %less, %more, %man and %clear/%cls, in zmq shell....
r3005 """Show a file through the pager.
Files ending in .py are syntax-highlighted."""
Bradley M. Froehle
Better error messages for common magic commands....
r8278 if not arg_s:
raise UsageError('Missing filename.')
Fernando Perez
Add init_environment(), %less, %more, %man and %clear/%cls, in zmq shell....
r3005 cont = open(arg_s).read()
if arg_s.endswith('.py'):
Jörgen Stenarson
merge functionality in io and openpy relating to encoding...
r8304 cont = self.shell.pycolorize(openpy.read_py_file(arg_s, skip_encoding_cookie=False))
else:
cont = open(arg_s).read()
Fernando Perez
Add init_environment(), %less, %more, %man and %clear/%cls, in zmq shell....
r3005 page.page(cont)
MinRK
update zmq shell magics...
r7076 more = line_magic('more')(less)
Fernando Perez
Add init_environment(), %less, %more, %man and %clear/%cls, in zmq shell....
r3005
# Man calls a pager, so we also need to redefine it
if os.name == 'posix':
MinRK
update zmq shell magics...
r7076 @line_magic
def man(self, arg_s):
Fernando Perez
Add init_environment(), %less, %more, %man and %clear/%cls, in zmq shell....
r3005 """Find the man page for the given command and display in pager."""
Fernando Perez
Fix for 'man' formatting (mostly on OSX, but the fix is OK on linux)
r3018 page.page(self.shell.getoutput('man %s | col -b' % arg_s,
split=False))
Brian Granger
Initial support in ipkernel for proper displayhook handling.
r2786
MinRK
update zmq shell magics...
r7076 @line_magic
def connect_info(self, arg_s):
MinRK
add %connect_info magic for help connecting secondary clients
r4964 """Print information for connecting other clients to this kernel
It will print the contents of this session's connection file, as well as
shortcuts for local clients.
In the simplest case, when called from the most recently launched kernel,
secondary clients can be connected, simply with:
$> ipython <app> --existing
"""
MinRK
update %connect_info magic to cover non-default cases...
r5184
from IPython.core.application import BaseIPythonApplication as BaseIPApp
if BaseIPApp.initialized():
app = BaseIPApp.instance()
security_dir = app.profile_dir.security_dir
profile = app.profile
else:
profile = 'default'
security_dir = ''
MinRK
add %connect_info magic for help connecting secondary clients
r4964 try:
MinRK
add IPython.lib.kernel...
r4970 connection_file = get_connection_file()
info = get_connection_info(unpack=False)
MinRK
add %connect_info magic for help connecting secondary clients
r4964 except Exception as e:
MinRK
add IPython.lib.kernel...
r4970 error("Could not get connection info: %r" % e)
MinRK
add %connect_info magic for help connecting secondary clients
r4964 return
MinRK
update %connect_info magic to cover non-default cases...
r5184
# add profile flag for non-default profile
profile_flag = "--profile %s" % profile if profile != 'default' else ""
# if it's in the security dir, truncate to basename
if security_dir == os.path.dirname(connection_file):
connection_file = os.path.basename(connection_file)
MinRK
add IPython.lib.kernel...
r4970 print (info + '\n')
MinRK
add %connect_info magic for help connecting secondary clients
r4964 print ("Paste the above JSON into a file, and connect with:\n"
" $> ipython <app> --existing <file>\n"
"or, if you are local, you can connect with just:\n"
MinRK
update %connect_info magic to cover non-default cases...
r5184 " $> ipython <app> --existing {0} {1}\n"
MinRK
add %connect_info magic for help connecting secondary clients
r4964 "or even just:\n"
MinRK
update %connect_info magic to cover non-default cases...
r5184 " $> ipython <app> --existing {1}\n"
"if this is the most recent IPython session you have started.".format(
connection_file, profile_flag
)
MinRK
add %connect_info magic for help connecting secondary clients
r4964 )
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
update zmq shell magics...
r7076 @line_magic
def qtconsole(self, arg_s):
MinRK
add %qtconsole magic for conveniently launching second console
r4965 """Open a qtconsole connected to this kernel.
Useful for connecting a qtconsole to running notebooks, for better
debugging.
"""
MinRK
%qtconsole implied bind_kernel on engines
r7313
# %qtconsole should imply bind_kernel for engines:
try:
from IPython.parallel import bind_kernel
except ImportError:
# technically possible, because parallel has higher pyzmq min-version
pass
else:
bind_kernel()
MinRK
add IPython.lib.kernel...
r4970 try:
MinRK
split qtconsole's connection-file search into lib.kernel...
r4972 p = connect_qtconsole(argv=arg_split(arg_s, os.name=='posix'))
MinRK
add IPython.lib.kernel...
r4970 except Exception as e:
error("Could not start qtconsole: %r" % e)
MinRK
add %qtconsole magic for conveniently launching second console
r4965 return
MinRK
add %autosave magic from autosave extension
r10510
@line_magic
def autosave(self, arg_s):
MinRK
autosave docstring
r10517 """Set the autosave interval in the notebook (in seconds).
MinRK
add %autosave magic from autosave extension
r10510
The default value is 120, or two minutes.
``%autosave 0`` will disable autosave.
MinRK
autosave docstring
r10517
This magic only has an effect when called from the notebook interface.
It has no effect when called in a startup file.
MinRK
add %autosave magic from autosave extension
r10510 """
try:
interval = int(arg_s)
except ValueError:
raise UsageError("%%autosave requires an integer, got %r" % arg_s)
# javascript wants milliseconds
milliseconds = 1000 * interval
display(Javascript("IPython.notebook.set_autosave_interval(%i)" % milliseconds),
include=['application/javascript']
)
if interval:
print("Autosaving every %i seconds" % interval)
else:
print("Autosave disabled")
MinRK
add %qtconsole magic for conveniently launching second console
r4965
MinRK
update zmq shell magics...
r7076
class ZMQInteractiveShell(InteractiveShell):
"""A subclass of InteractiveShell for ZMQ."""
displayhook_class = Type(ZMQShellDisplayHook)
display_pub_class = Type(ZMQDisplayPublisher)
MinRK
add data_pub messages...
r8102 data_pub_class = Type(ZMQDataPublisher)
MinRK
zmqshell has handle on Kernel
r13199 kernel = Any()
MinRK
make parent_header available from the Shell object
r13222 parent_header = Any()
MinRK
add kernel banner to terminal and qt frontends
r16583
def _banner1_default(self):
return default_gui_banner
MinRK
update zmq shell magics...
r7076
# Override the traitlet in the parent class, because there's no point using
# readline for the kernel. Can be removed when the readline code is moved
# to the terminal frontend.
colors_force = CBool(True)
readline_use = CBool(False)
# autoindent has no meaning in a zmqshell, and attempting to enable it
# will print a warning in the absence of readline.
autoindent = CBool(False)
exiter = Instance(ZMQExitAutocall)
def _exiter_default(self):
return ZMQExitAutocall(self)
def _exit_now_changed(self, name, old, new):
"""stop eventloop when exit_now fires"""
if new:
loop = ioloop.IOLoop.instance()
loop.add_timeout(time.time()+0.1, loop.stop)
keepkernel_on_exit = None
# Over ZeroMQ, GUI control isn't done with PyOS_InputHook as there is no
# interactive input being read; we provide event loop support in ipkernel
MinRK
raise UsageError for unsupported GUI backends...
r11319 @staticmethod
def enable_gui(gui):
from .eventloops import enable_gui as real_enable_gui
try:
real_enable_gui(gui)
except ValueError as e:
raise UsageError("%s" % e)
MinRK
update zmq shell magics...
r7076
def init_environment(self):
"""Configure the user's environment.
"""
env = os.environ
# These two ensure 'ls' produces nice coloring on BSD-derived systems
env['TERM'] = 'xterm-color'
env['CLICOLOR'] = '1'
# Since normal pagers don't work at all (over pexpect we don't have
# single-key control of the subprocess), try to disable paging in
# subprocesses as much as possible.
env['PAGER'] = 'cat'
env['GIT_PAGER'] = 'cat'
# And install the payload version of page.
install_payload_page()
def ask_exit(self):
"""Engage the exit actions."""
MinRK
use ask_exit payload in terminal console...
r17325 self.exit_now = (not self.keepkernel_on_exit)
MinRK
update zmq shell magics...
r7076 payload = dict(
MinRK
update payload source...
r11839 source='ask_exit',
MinRK
update zmq shell magics...
r7076 keepkernel=self.keepkernel_on_exit,
)
self.payload_manager.write_payload(payload)
def _showtraceback(self, etype, evalue, stb):
MinRK
flush output before showing tracebacks...
r14880 # try to preserve ordering of tracebacks and print statements
sys.stdout.flush()
sys.stderr.flush()
MinRK
update zmq shell magics...
r7076
exc_content = {
u'traceback' : stb,
Thomas Kluyver
Replace references to unicode and basestring
r13353 u'ename' : unicode_type(etype.__name__),
MinRK
move safe_unicode to py3compat
r10635 u'evalue' : py3compat.safe_unicode(evalue),
MinRK
update zmq shell magics...
r7076 }
dh = self.displayhook
# Send exception info over pub socket for other clients than the caller
# to pick up
topic = None
if dh.topic:
MinRK
pyerr -> error
r16569 topic = dh.topic.replace(b'execute_result', b'error')
MinRK
update zmq shell magics...
r7076
MinRK
pyerr -> error
r16569 exc_msg = dh.session.send(dh.pub_socket, u'error', json_clean(exc_content), dh.parent_header, ident=topic)
MinRK
update zmq shell magics...
r7076
# FIXME - Hack: store exception info in shell object. Right now, the
# caller is reading this info after the fact, we need to fix this logic
# to remove this hack. Even uglier, we need to store the error status
# here, because in the main loop, the logic that sets it is being
# skipped because runlines swallows the exceptions.
exc_content[u'status'] = u'error'
self._reply_content = exc_content
# /FIXME
return exc_content
Thomas Kluyver
Machinery to replace the current cell instead of adding a new one
r19250 def set_next_input(self, text, replace=False):
Thomas Kluyver
Add set_next_input method to ZMQInteractiveShell, so that %recall can put code at the next prompt.
r3864 """Send the specified text to the frontend to be presented at the next
input cell."""
Brian Granger
Implemented %loadpy magic for loading .py scripts into Qt console.
r3036 payload = dict(
MinRK
update payload source...
r11839 source='set_next_input',
Thomas Kluyver
Machinery to replace the current cell instead of adding a new one
r19250 text=text,
replace=replace,
Brian Granger
Implemented %loadpy magic for loading .py scripts into Qt console.
r3036 )
self.payload_manager.write_payload(payload)
MinRK
update zmq shell magics...
r7076
MinRK
add ZMQShell.set_parent...
r13200 def set_parent(self, parent):
"""Set the parent header for associating output with its triggering input"""
MinRK
make parent_header available from the Shell object
r13222 self.parent_header = parent
MinRK
add ZMQShell.set_parent...
r13200 self.displayhook.set_parent(parent)
self.display_pub.set_parent(parent)
self.data_pub.set_parent(parent)
try:
sys.stdout.set_parent(parent)
except AttributeError:
pass
try:
sys.stderr.set_parent(parent)
except AttributeError:
pass
MinRK
make parent_header available from the Shell object
r13222 def get_parent(self):
return self.parent_header
MinRK
update zmq shell magics...
r7076 #-------------------------------------------------------------------------
# Things related to magics
#-------------------------------------------------------------------------
def init_magics(self):
super(ZMQInteractiveShell, self).init_magics()
self.register_magics(KernelMagics)
Bradley M. Froehle
Use magic alias api to register magic aliases.
r7933 self.magics_manager.register_alias('ed', 'edit')
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
Fernando Perez
Refactor gui/pylab integration to eliminate code duplication....
r5469
Fernando Perez
Improvements to exception handling to transport structured tracebacks....
r2838 InteractiveShellABC.register(ZMQInteractiveShell)