Re: Embedded shell setup
Matthias Bussonnier <[email protected]>
| Newsgroups | gmane.comp.python.ipython.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Frederic. I haven’t used IPython 0.7.2 but I can try to give you some feedback. > On Dec 1, 2015, at 08:29, Frédéric Mantegazza <[email protected]> wrote: > > 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 I’m not sure this assignment will work, because of what the config object works. In doubt I would explicitly use config.PromptManager.in/out_template if you have issues. I would have to try and check that. > promptManager.in_template = "{color.LightRed}PyMAD>>> " > promptManager.out_template = ‘ ' > # profile is not loaded does not work! > config.profile = “pymad" I’m not sure what yo are trying to do. I guess you might want to load a subconfia from another profile ? https://ipython.org/ipython-doc/2/development/config.html?highlight=load_subconfig#configuration-files-inheritance <https://ipython.org/ipython-doc/2/development/config.html?highlight=load_subconfig#configuration-files-inheritance> InteractiveShellEmbed is not a subclass of BaseIPythonApplication, so it does not seem have a `profile` configuration. The way it works in IPython is TerminalIPythonApp in init_shell call the following: def init_shell(self): ... self.shell = TerminalInteractiveShell.instance(parent=self, ..., profile_dir=self.profile_dir, ipython_dir=self.ipython_dir, ...) > 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) > I’m not familiar enough with completion, I know that holoview register its own completer: https://github.com/ioam/holoviews/blob/master/holoviews/ipython/magics.py#L697-L717 <https://github.com/ioam/holoviews/blob/master/holoviews/ipython/magics.py#L697-L717> it might be of help. > # 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 > I’ll leave this one up to someone else also, likely Thomas maybe ? > # 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 > Thanks, -- M _______________________________________________ IPython-dev mailing list [email protected] https://mail.scipy.org/mailman/listinfo/ipython-dev