Embedded shell setup

Frédéric Mantegazza <[email protected]>
Newsgroups gmane.comp.python.ipython.devel
Organization CEA-Grenoble
Message-ID <[email protected]>
Hi!

In 2003, we started to develop an application to drive a big instrument
(a neutron spectrometer), in a french research institute. Since 2004, this
application runs 24h a day, almost all days.

It is entirely written in python, and is heavily based on Pyro for
clients/servers communication, and, of course IPython, for user
interaction.

With these 2 great pieces of code, we have build a very strong tool.
Fernando helped us a lot to customize IPython, and integrate it in our
code. Thanks again for all your help, Fernando!

Even if our app. evolved during all these years, it is still based on
softwares versions of the early 2k (debian lenny, IPython 0.7.2, Pyro
3.7) :o/

It is time to do a major upgrade! That's why we need some help...

Here is what we are doing when we instanciate what we call the
'console' (client part of our app.); we already adapted it to IPython 2.3,
but there are still things which does not work (loading 'pymad' profile),
and surely thing which could be better (hooks, custom completer...).

We would really appreciate feedback!

Thanks,

----------------------------------------------------------------

config = IPython.config.loader.Config()
promptManager = config.PromptManager
promptManager.in_template = "{color.LightRed}PyMAD>>> "
promptManager.out_template = ' '
# profile is not loaded does not work!
config.profile = "pymad"
startMsg = "\nWelcome to PyMAD"
startMsg += "\n\nAvailable objects: %s " % sortedProxies
startMsg += "\n\nAvailable helpers: %s\n" % helpers.keys()
exitMsg = "\nBye!\n"

# Instanciate embedded ipython instance
ipshell = InteractiveShellEmbed(config,
                                banner1=startMsg,
                                exit_msg=exitMsg)

ipshell.set_custom_exc((Exception, ), pymadHandler)
ipshell.set_custom_completer(proxy_matches)
ipshell.set_custom_completer(python_function_parameters)

# Is there a better way to customize Completer?
ipshell.Completer._default_arguments = \
    new.instancemethod(_default_arguments,
                       ipshell.Completer,
                       ipshell.Completer.__class__)
ipshell.Completer.merge_completions = False

# Is there a better way to customize prefilter?
ipshell.prefilter = new.instancemethod(_prefilter_del,
                                       ipshell,
                                       ipshell.__class__)

ipshell.set_hook("pre_run_code_hook", _pre_run_code_hook)
ipshell.set_hook("pre_prompt_hook", _pre_prompt_hook)
#ipshell.set_hook("shutdown_hook", _shutdown_hook) # use atexit module

-- 
    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.