def __init__(self, argv=None, user_ns=None, user_global_ns=None, debug=0, shell_class=MTInteractiveShell): import qt self.exec_loop = hijack_qt() # Allows us to use both Tk and QT. self.tk = get_tk() self.IP = make_IPython(argv, user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[qt.qApp.exit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
def __init__(self,argv=None,user_ns=None,user_global_ns=None, debug=1,shell_class=MTInteractiveShell): import gtk self.gtk = gtk self.gtk_mainloop = hijack_gtk() # Allows us to use both Tk and GTK. self.tk = get_tk() if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit else: mainquit = self.gtk.mainquit self.IP = make_IPython(argv,user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[mainquit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
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, user_ns=None, debug=1, shell_class=TwistedInteractiveShell): from twisted.internet import reactor self.reactor = hijack_reactor() mainquit = self.reactor.stop # Make sure IPython keeps going after reactor stop. def reactorstop(): pass self.reactor.stop = reactorstop reactorrun_orig = self.reactor.run self.quitting = False def reactorrun(): while True and not self.quitting: reactorrun_orig() self.reactor.run = reactorrun self.IP = make_IPython(argv, user_ns=user_ns, debug=debug, shell_class=shell_class, on_kill=[mainquit])
def __init__(self, argv=None, user_ns=None, debug=1, shell_class=MTInteractiveShell): import pygtk pygtk.require("2.0") import gtk self.gtk = gtk self.gtk_mainloop = hijack_gtk() # Allows us to use both Tk and GTK. self.tk = get_tk() if gtk.pygtk_version >= (2, 4, 0): mainquit = self.gtk.main_quit else: mainquit = self.gtk.mainquit self.IP = make_IPython(argv, user_ns=user_ns, debug=debug, shell_class=shell_class, on_kill=[mainquit]) threading.Thread.__init__(self)
def __init__(self, argv=None, banner='', exit_msg=None, rc_override=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 # FIXME. Passing user_ns breaks namespace handling. #self.IP = make_IPython(argv,user_ns=__main__.__dict__) self.IP = make_IPython(argv, rc_override=rc_override, embedded=True) self.IP.name_space_init() # mark this as an embedded instance so we know if we get a crash # post-mortem self.IP.rc.embedded = 1 # 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 __init__(self, argv=None, user_ns=None, debug=0, shell_class=MTInteractiveShell): import qt class newQApplication: def __init__(self): self.QApplication = qt.QApplication def __call__(*args, **kwargs): return qt.qApp def exec_loop(*args, **kwargs): pass def __getattr__(self, name): return getattr(self.QApplication, name) qt.QApplication = newQApplication() # Allows us to use both Tk and QT. self.tk = get_tk() self.IP = make_IPython(argv, user_ns=user_ns, debug=debug, shell_class=shell_class, on_kill=[qt.qApp.exit]) threading.Thread.__init__(self)
def __init__(self, argv=None, user_ns=None, user_global_ns=None, debug=0, shell_class=MTInteractiveShell): from PyQt4 import QtCore, QtGui try: # present in PyQt4-4.2.1 or later QtCore.pyqtRemoveInputHook() except AttributeError: pass if QtCore.PYQT_VERSION_STR == '4.3': warn('''PyQt4 version 4.3 detected. If you experience repeated threading warnings, please update PyQt4. ''') self.exec_ = hijack_qt4() # Allows us to use both Tk and QT. self.tk = get_tk() self.IP = make_IPython(argv, user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[QtGui.qApp.exit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
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 __init__(self, argv=None, user_ns=None, user_global_ns=None, debug=1, shell_class=MTInteractiveShell): import gtk self.gtk = gtk self.gtk_mainloop = hijack_gtk() # Allows us to use both Tk and GTK. self.tk = get_tk() if gtk.pygtk_version >= (2, 4, 0): mainquit = self.gtk.main_quit else: mainquit = self.gtk.mainquit self.IP = make_IPython(argv, user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[mainquit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
def __init__(self,argv=None,user_ns=None,user_global_ns=None, debug=0,shell_class=MTInteractiveShell): from PyQt4 import QtCore, QtGui class newQApplication: def __init__( self ): self.QApplication = QtGui.QApplication def __call__( *args, **kwargs ): return QtGui.qApp def exec_loop( *args, **kwargs ): pass def __getattr__( self, name ): return getattr( self.QApplication, name ) QtGui.QApplication = newQApplication() # Allows us to use both Tk and QT. self.tk = get_tk() self.IP = make_IPython(argv,user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[QtGui.qApp.exit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
def __init__(self, locals): self.locals = locals self.interpreter = make_IPython(argv=[],embedded=True,user_global_ns=self.locals) self.interpreter.set_hook('result_display',result_display) color = self.interpreter.rc.colors self.interpreter.InteractiveTB = AutoFormattedTB(mode = 'Plain', color_scheme=color, tb_offset = 1) self.interpreter.SyntaxTB = SyntaxTB(color_scheme=color)
def __init__(self, argv=None, user_ns=None, debug=1, shell_class=InteractiveShell): self.IP = make_IPython(argv, user_ns=user_ns, debug=debug, shell_class=shell_class)
def reset(self): """Resets the namespace""" #TODO: fix this oldpath = sys.path[:] self.IP = make_IPython(self.argv, user_ns=self.user_ns.copy(), debug=self.debug, shell_class=self.shell_class) sys.path = oldpath
def __init__(self,argv=None,user_ns=None,debug=1, shell_class=MTInteractiveShell): import wxPython.wx as wx threading.Thread.__init__(self) self.wx = wx self.wx_mainloop = hijack_wx() # Allows us to use both Tk and GTK. self.tk = get_tk() self.IP = make_IPython(argv,user_ns=user_ns,debug=debug, shell_class=shell_class, on_kill=[self.wxexit]) self.app = None
def __init__(self, ipython0=None, *args, **kwargs): """ Parameters: ----------- ipython0: an optional ipython0 instance to use for command prefiltering and completion. """ LineFrontEndBase.__init__(self, *args, **kwargs) self.shell.output_trap = RedirectorOutputTrap( out_callback=self.write, err_callback=self.write, ) self.shell.traceback_trap = SyncTracebackTrap( formatters=self.shell.traceback_trap.formatters, ) # Start the ipython0 instance: self.save_output_hooks() if ipython0 is None: # Instanciate an IPython0 interpreter to be able to use the # prefiltering. # XXX: argv=[] is a bit bold. ipython0 = make_IPython(argv=[], user_ns=self.shell.user_ns, user_global_ns=self.shell.user_global_ns) self.ipython0 = ipython0 # Set the pager: self.ipython0.set_hook('show_in_pager', lambda s, string: self.write("\n" + string)) self.ipython0.write = self.write self._ip = _ip = IPApi(self.ipython0) # Make sure the raw system call doesn't get called, as we don't # have a stdin accessible. self._ip.system = self.system_call # XXX: Muck around with magics so that they work better # in our environment self.ipython0.magic_ls = mk_system_call(self.system_call, 'ls -CF') # And now clean up the mess created by ipython0 self.release_output() if not 'banner' in kwargs and self.banner is None: self.banner = self.ipython0.BANNER + """ This is the wx frontend, by Gael Varoquaux. This is EXPERIMENTAL code.""" self.start()
def __init__(self, argv=None, user_ns=None, debug=1, shell_class=InteractiveShell): self.argv = argv self.user_ns = user_ns self.debug = debug self.shell_class = shell_class #Save sys.path oldpath = sys.path[:] #oldpath=sys.path would only make a reference, not copy the list self.IP = make_IPython(self.argv, user_ns=self.user_ns.copy(), debug=self.debug, shell_class=self.shell_class) #restore sys.path sys.path = oldpath
def __init__(self, argv=None, user_ns=None, user_global_ns=None, debug=1, shell_class=MTInteractiveShell): self.IP = make_IPython(argv, user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[self.wxexit]) wantedwxversion = self.IP.rc.wxversion if wantedwxversion != "0": try: import wxversion except ImportError: error( 'The wxversion module is needed for WX version selection') else: try: wxversion.select(wantedwxversion) except: self.IP.InteractiveTB() error('Requested wxPython version %s could not be loaded' % wantedwxversion) import wxPython.wx as wx threading.Thread.__init__(self) self.wx = wx self.wx_mainloop = hijack_wx() # Allows us to use both Tk and GTK. self.tk = get_tk() # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None self.app = None
def __init__(self, argv=None, user_ns=None, user_global_ns=None, debug=1, shell_class=MTInteractiveShell): import gtk # Check for set_interactive, coming up in new pygtk. # Disable it so that this code works, but notify # the user that he has a better option as well. # XXX TODO better support when set_interactive is released try: gtk.set_interactive(False) print "Your PyGtk has set_interactive(), so you can use the" print "more stable single-threaded Gtk mode." print "See https://bugs.launchpad.net/ipython/+bug/270856" except AttributeError: pass self.gtk = gtk self.gtk_mainloop = hijack_gtk() # Allows us to use both Tk and GTK. self.tk = get_tk() if gtk.pygtk_version >= (2, 4, 0): mainquit = self.gtk.main_quit else: mainquit = self.gtk.mainquit self.IP = make_IPython(argv, user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[mainquit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
def __init__(self,argv=None,user_ns=None,user_global_ns=None, debug=1,shell_class=MTInteractiveShell): self.IP = make_IPython(argv,user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[self.wxexit]) wantedwxversion=self.IP.rc.wxversion if wantedwxversion!="0": try: import wxversion except ImportError: error('The wxversion module is needed for WX version selection') else: try: wxversion.select(wantedwxversion) except: self.IP.InteractiveTB() error('Requested wxPython version %s could not be loaded' % wantedwxversion) import wx threading.Thread.__init__(self) self.wx = wx self.wx_mainloop = hijack_wx() # Allows us to use both Tk and GTK. self.tk = get_tk() # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None self.app = None
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,user_ns=None,user_global_ns=None, debug=1,shell_class=MTInteractiveShell): import gtk ## # Check for set_interactive, coming up in new pygtk. ## # Disable it so that this code works, but notify ## # the user that he has a better option as well. ## # XXX TODO better support when set_interactive is released ## try: gtk.set_interactive(False) ## print "Your PyGtk has set_interactive(), so you can use the" ## print "more stable single-threaded Gtk mode." ## print "See https://bugs.launchpad.net/ipython/+bug/270856" ## except AttributeError: ## pass self.gtk = gtk self.gtk_mainloop = hijack_gtk() # Allows us to use both Tk and GTK. self.tk = get_tk() if gtk.pygtk_version >= (2,4,0): mainquit = self.gtk.main_quit else: mainquit = self.gtk.mainquit self.IP = make_IPython(argv,user_ns=user_ns, user_global_ns=user_global_ns, debug=debug, shell_class=shell_class, on_kill=[mainquit]) # HACK: slot for banner in self; it will be passed to the mainloop # method only and .run() needs it. The actual value will be set by # .mainloop(). self._banner = None threading.Thread.__init__(self)
def __init__(self,argv=None,user_ns=None,user_global_ns=None, debug=1,shell_class=InteractiveShell): self.IP = make_IPython(argv,user_ns=user_ns, user_global_ns=user_global_ns, debug=debug,shell_class=shell_class)
def __init__(self, ipython0=None, argv=None, *args, **kwargs): """ Parameters ---------- ipython0: an optional ipython0 instance to use for command prefiltering and completion. argv : list, optional Used as the instance's argv value. If not given, [] is used. """ if argv is None: argv = [] # This is a hack to avoid the IPython exception hook to trigger # on exceptions (https://bugs.launchpad.net/bugs/337105) # XXX: This is horrible: module-leve monkey patching -> side # effects. from IPython import iplib iplib.InteractiveShell.isthreaded = True LineFrontEndBase.__init__(self, *args, **kwargs) self.shell.output_trap = RedirectorOutputTrap( out_callback=self.write, err_callback=self.write, ) self.shell.traceback_trap = SyncTracebackTrap( formatters=self.shell.traceback_trap.formatters, ) # Start the ipython0 instance: self.save_output_hooks() if ipython0 is None: # Instanciate an IPython0 interpreter to be able to use the # prefiltering. # Suppress all key input, to avoid waiting def my_rawinput(x=None): return '\n' old_rawinput = __builtin__.raw_input __builtin__.raw_input = my_rawinput # XXX: argv=[] is a bit bold. ipython0 = make_IPython(argv=argv, user_ns=self.shell.user_ns, user_global_ns=self.shell.user_global_ns) __builtin__.raw_input = old_rawinput self.ipython0 = ipython0 # Set the pager: self.ipython0.set_hook('show_in_pager', lambda s, string: self.write("\n" + string)) self.ipython0.write = self.write self._ip = _ip = IPApi(self.ipython0) # Make sure the raw system call doesn't get called, as we don't # have a stdin accessible. self._ip.system = self.system_call # XXX: Muck around with magics so that they work better # in our environment if not sys.platform.startswith('win'): self.ipython0.magic_ls = mk_system_call(self.system_call, 'ls -CF') # And now clean up the mess created by ipython0 self.release_output() if not 'banner' in kwargs and self.banner is None: self.banner = self.ipython0.BANNER # FIXME: __init__ and start should be two different steps self.start()