[IPython-dev] Using jupyter_console as embedded shell
Frédéric Mantegazza
mantegazza at ill.fr
Thu Dec 3 07:01:59 EST 2015
Le 03/12/2015, Thomas a écrit :
> The kernel is the process that loads IPython and handles execution, tab
> completion, and so on. Almost everything that's specific to dealing with
> Python code happens in the kernel
Ok. Based on this code:
https://github.com/ipython/ipykernel/blob/master/ipykernel/embed.py
I successfully started the kernel, and connected several console to it.
But my config (prompt, completion, exceptions behaviour...) is not taken
into account. What did I miss?
Here is my code:
from ipykernel.kernelapp import IPKernelApp
from traitlets.config.loader import Config
config = Config()
promptManager = config.PromptManager
promptManager.in_template = "{color.LightGreen}Simul>>> "
startMsg = "\nWelcome to PyMAD"
startMsg += "\n\nAvailable objects: %s " % sortedProxies
startMsg += "\n\nAvailable helpers: %s\n" % helpers.keys()
exitMsg = "\nBye!\n"
app = IPKernelApp.instance(config=config,
banner1=startMsg,
exit_msg=exitMsg)
app.initialize([])
app.shell.set_custom_exc((Exception, ), pymadHandler)
app.shell.set_custom_completer(proxy_matches)
app.shell.Completer.merge_completions = False
app.shell.set_hook("pre_prompt_hook", pre_prompt_hook)
app.shell.events.register('pre_execute', pre_execute)
app.shell.register_magics(ServerMagics)
app.kernel.user_ns = context
app.start()
--
Frédéric MANTEGAZZA CEA-Grenoble
Tel. : 33 (0) 476 207 617 INAC/SPSMS/MDN
Fax : 33 (0) 476 483 906 17, rue des Martyrs
Courriel : mantegazza at ill.fr F-38054 Grenoble Cedex 09
More information about the IPython-dev
mailing list