Re: Using jupyter_console as embedded shell

Frédéric Mantegazza <[email protected]>
Newsgroups gmane.comp.python.ipython.devel
Organization CEA-Grenoble
Message-ID <[email protected]>
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 : [email protected]    F-38054 Grenoble Cedex 09

_______________________________________________
IPython-dev mailing list
[email protected]
https://mail.scipy.org/mailman/listinfo/ipython-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.