def __init__(self, argv=None, banner='', exit_msg=None, rc_override=None, user_ns=None, callback=None): self.set_banner(banner) self.set_exit_msg(exit_msg) self.set_dummy_mode(0) self.sys_displayhook_ori = sys.displayhook try: self.sys_ipcompleter_ori = sys.ipcompleter except: pass self.IP = make_IPython(argv, rc_override=rc_override, embedded=True, user_ns=user_ns, shell_class=InteractiveShellMadcow) self.IP.callback = callback ip = ipapi.IPApi(self.IP) ip.expose_magic(u"kill_embedded", kill_embedded) self.sys_displayhook_embed = sys.displayhook sys.displayhook = self.sys_displayhook_ori sys.excepthook = ultraTB.FormattedTB(color_scheme=self.IP.rc.colors, mode=self.IP.rc.xmode, call_pdb=self.IP.rc.pdb) self.restore_system_completer()
def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None, user_ns=None): """Note that argv here is a string, NOT a list.""" self.set_banner(banner) self.set_exit_msg(exit_msg) self.set_dummy_mode(0) # sys.displayhook is a global, we need to save the user's original # Don't rely on __displayhook__, as the user may have changed that. self.sys_displayhook_ori = sys.displayhook # save readline completer status try: #print 'Save completer',sys.ipcompleter # dbg self.sys_ipcompleter_ori = sys.ipcompleter except: pass # not nested with IPython self.IP = make_IPython(argv,rc_override=rc_override, embedded=True, user_ns=user_ns) ip = ipapi.IPApi(self.IP) ip.expose_magic("kill_embedded",kill_embedded) # copy our own displayhook also self.sys_displayhook_embed = sys.displayhook # and leave the system's display hook clean sys.displayhook = self.sys_displayhook_ori # don't use the ipython crash handler so that user exceptions aren't # trapped sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors, mode = self.IP.rc.xmode, call_pdb = self.IP.rc.pdb) self.restore_system_completer()
def _execipyshell(ui): """Setup IPython shell and enter mainloop""" ns = {} for mod in (QtCore, QtGui): ns.update( (k, v) for k, v in vars(mod).iteritems() if not k.startswith('_')) ns.update({ 'dialogs': run.qtrun._dialogs, 'repos': thgrepo._repocache, 'run': run, 'ui': ui }) shell = IPShellQt4(argv=[], user_ns=ns) ip = ipapi.IPApi(shell.IP) ip.expose_magic('hg', _runhgcommand) ip.expose_magic('thg', _runthgcommand) shell.mainloop(banner=_banner())