Exemple #1
0
    def __init__(self):
        """Constructor.

        Imports IPython's embedded shell with separator lines removed."""
        Shell.__init__(self)
        ConsoleProgressBarMixin.__init__(self)

        # We cannot use IPShellEmbed here because generator expressions do not
        # work there (e.g., set(g.degree(x) for x in [1,2,3])) where g comes
        # from an external context
        import sys

        from IPython import __version__ as ipython_version
        self.ipython_version = ipython_version

        try:
            # IPython >= 0.11 supports this
            from IPython.frontend.terminal.ipapp import TerminalIPythonApp
            self._shell = TerminalIPythonApp.instance()
            sys.argv.append("--nosep")
        except ImportError:
            # IPython 0.10 and earlier
            import IPython.Shell
            self._shell = IPython.Shell.start()
            self._shell.IP.runsource("from igraph import *")
            sys.argv.append("-nosep")
Exemple #2
0
 def ipython_start(self):
     from IPython.frontend.terminal.ipapp import TerminalIPythonApp
     ip = TerminalIPythonApp.instance()
     ip.initialize(argv=[])
     for key, value in self.global_namespace().items():
         ip.shell.user_global_ns[key] = value
     ip.start()
Exemple #3
0
    def _ipython_pre_100(self):
        """Start IPython pre-1.0.0"""
        from IPython.frontend.terminal.ipapp import TerminalIPythonApp

        app = TerminalIPythonApp.instance()
        app.initialize(argv=[])
        app.start()
Exemple #4
0
 def ipython_start(self):
     from IPython.frontend.terminal.ipapp import TerminalIPythonApp
     ip = TerminalIPythonApp.instance()
     ip.initialize(argv=[])
     for key, value in self.global_namespace().items():
         ip.shell.user_global_ns[key] = value
     ip.start()
    def __init__(self):
        """Constructor.

        Imports IPython's embedded shell with separator lines removed."""
        Shell.__init__(self)
        ConsoleProgressBarMixin.__init__(self)

        # We cannot use IPShellEmbed here because generator expressions do not
        # work there (e.g., set(g.degree(x) for x in [1,2,3])) where g comes
        # from an external context
        import sys

        from IPython import __version__ as ipython_version
        self.ipython_version = ipython_version

        try:
            # IPython >= 0.11 supports this
            from IPython.frontend.terminal.ipapp import TerminalIPythonApp
            self._shell = TerminalIPythonApp.instance()
            sys.argv.append("--nosep")
        except ImportError:
            # IPython 0.10 and earlier
            import IPython.Shell
            self._shell = IPython.Shell.start()
            self._shell.IP.runsource("from igraph import *")
            sys.argv.append("-nosep")
Exemple #6
0
    def _ipython_pre_10(self):  # pragma: no cover
        from IPython.frontend.terminal.ipapp import TerminalIPythonApp

        app = TerminalIPythonApp.instance()
        app.initialize(argv=[])
        app.shell.user_ns.update(self.locals)
        app.start()
Exemple #7
0
    def _ipython_pre_100(self):
        """Start IPython pre-1.0.0"""
        from IPython.frontend.terminal.ipapp import TerminalIPythonApp

        app = TerminalIPythonApp.instance()
        app.initialize(argv=[])
        user_ns = self.get_start_namespace()
        if user_ns:
            app.shell.user_ns.update(user_ns)
        app.start()
Exemple #8
0
def _ipython_pre_100():
    """Start IPython pre-1.0.0"""
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp  # pylint: disable=import-error,no-name-in-module

    app = TerminalIPythonApp.instance()
    app.initialize(argv=[])
    user_ns = get_start_namespace()
    if user_ns:
        app.shell.user_ns.update(user_ns)
    app.start()
Exemple #9
0
def debug_shell(app):
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp
    ip = TerminalIPythonApp.instance()
    ip.initialize(argv=[])
    ip.shell.user_global_ns['app'] = app
    ip.shell.user_global_ns['repo'] = app.repo
    ip.shell.user_global_ns['git'] = app.git
    ip.shell.user_global_ns['trac'] = app.trac
    def ipy_import(module_name, identifier):
        module = importlib.import_module(module_name)
        ip.shell.user_global_ns[identifier] = getattr(module, identifier) 
    ipy_import('git_trac.git_interface', 'GitInterface')
    ipy_import('git_trac.trac_server', 'TracServer')
    ip.start()
Exemple #10
0
def start_ipymote():
    import os
    import sys
    if sys.platform.startswith("win32") or sys.platform.startswith("linux2"):
        try:
            os.environ['VIRTUAL_ENV'] = os.environ['PYMOTE_ENV']
            os.environ['IPYTHONDIR'] = os.path.join(os.environ['PYMOTE_ENV'],
                                                    '.ipython')
        except KeyError:
            pass

        from IPython.frontend.terminal.ipapp import TerminalIPythonApp
        app = TerminalIPythonApp.instance()
        app.initialize(argv=['--profile=pymote'])
        app.start()
Exemple #11
0
def start_ipymote():
    import os
    import sys
    if sys.platform.startswith("win32") or sys.platform.startswith("linux2"):
        try:
            os.environ['VIRTUAL_ENV'] = os.environ['PYMOTE_ENV']
            os.environ['IPYTHONDIR'] = os.path.join(os.environ['PYMOTE_ENV'],
                                                    '.ipython')
        except KeyError:
            pass

        from IPython.frontend.terminal.ipapp import TerminalIPythonApp
        app = TerminalIPythonApp.instance()
        app.initialize(argv=['--profile=pymote'])
        app.start()
Exemple #12
0
    def debug_shell_gtk(self, app):
        from IPython.lib.inputhook import enable_gtk3
        enable_gtk3()
        from IPython.frontend.terminal.ipapp import TerminalIPythonApp
        ip = TerminalIPythonApp.instance()
        ip.initialize(argv=[])
        ip.shell.enable_gui('gtk3')
        ip.shell.user_global_ns['app'] = app

        def ipy_import(module_name, identifier):
            module = importlib.import_module(module_name)
            ip.shell.user_global_ns[identifier] = getattr(module, identifier)

        #ipy_import('sage_notebook.model.git_interface', 'GitInterface')
        ip.start()
Exemple #13
0
def debug_shell(app):
    from IPython.lib.inputhook import enable_gtk3
    enable_gtk3()
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp
    ip = TerminalIPythonApp.instance()
    ip.initialize(argv=[])
    ip.shell.enable_gui('gtk3')
    ip.shell.user_global_ns['app'] = app
    ip.shell.user_global_ns['repo'] = app.model.repo
    ip.shell.user_global_ns['git'] = app.model.repo.git
    def ipy_import(module_name, identifier):
        module = importlib.import_module(module_name)
        ip.shell.user_global_ns[identifier] = getattr(module, identifier) 
    ipy_import('sageui.model.git_interface', 'GitInterface')
    ipy_import('sageui.model.git_repository', 'GitRepository')
    ip.start()
Exemple #14
0
def debug_shell(app):
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp
    ip = TerminalIPythonApp.instance()
    ip.initialize(argv=[])
    ip.shell.user_global_ns['app'] = app
    ip.shell.user_global_ns['repo'] = app.repo
    ip.shell.user_global_ns['git'] = app.git
    ip.shell.user_global_ns['trac'] = app.trac

    def ipy_import(module_name, identifier):
        module = importlib.import_module(module_name)
        ip.shell.user_global_ns[identifier] = getattr(module, identifier)

    ipy_import('git_trac.git_interface', 'GitInterface')
    ipy_import('git_trac.trac_server', 'TracServer')
    ip.start()
Exemple #15
0
    def debug_shell_gtk(self, app):
        from IPython.lib.inputhook import enable_gtk3

        enable_gtk3()
        from IPython.frontend.terminal.ipapp import TerminalIPythonApp

        ip = TerminalIPythonApp.instance()
        ip.initialize(argv=[])
        ip.shell.enable_gui("gtk3")
        ip.shell.user_global_ns["app"] = app

        def ipy_import(module_name, identifier):
            module = importlib.import_module(module_name)
            ip.shell.user_global_ns[identifier] = getattr(module, identifier)

        # ipy_import('sage_notebook.model.git_interface', 'GitInterface')
        ip.start()
Exemple #16
0
 def ipython(self):
     try:
         from IPython.frontend.terminal.ipapp import TerminalIPythonApp
         app = TerminalIPythonApp.instance()
         app.initialize(argv=[])
         app.start()
     except ImportError:
         # IPython < 0.11
         # Explicitly pass an empty list as arguments, because otherwise
         # IPython would use sys.argv from this script.
         try:
             from IPython.Shell import IPShell
             shell = IPShell(argv=[])
             shell.mainloop()
         except ImportError:
             # IPython not found at all, raise ImportError
             raise
Exemple #17
0
 def ipython(self):
     try:
         from IPython.frontend.terminal.ipapp import TerminalIPythonApp
         app = TerminalIPythonApp.instance()
         app.initialize(argv=[])
         app.start()
     except ImportError:
         # IPython < 0.11
         # Explicitly pass an empty list as arguments, because otherwise
         # IPython would use sys.argv from this script.
         try:
             from IPython.Shell import IPShell
             shell = IPShell(argv=[])
             shell.mainloop()
         except ImportError:
             # IPython not found at all, raise ImportError
             raise
Exemple #18
0
def debug_shell(app):
    from IPython.lib.inputhook import enable_gtk3
    enable_gtk3()
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp
    ip = TerminalIPythonApp.instance()
    ip.initialize(argv=[])
    ip.shell.enable_gui('gtk3')
    ip.shell.user_global_ns['app'] = app
    ip.shell.user_global_ns['repo'] = app.model.repo
    ip.shell.user_global_ns['git'] = app.model.repo.git

    def ipy_import(module_name, identifier):
        module = importlib.import_module(module_name)
        ip.shell.user_global_ns[identifier] = getattr(module, identifier)

    ipy_import('sageui.model.git_interface', 'GitInterface')
    ipy_import('sageui.model.git_repository', 'GitRepository')
    ip.start()
Exemple #19
0
def _launch_qt_console(ppid, connection_file):
    """called as a new process"""
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp
    import threading
    import psutil
    import time
    
    # start a thread to kill this process when the parent process exits
    def thread_func():
        while True:
            if not psutil.pid_exists(ppid):
                os._exit(1)
            time.sleep(5)
    thread = threading.Thread(target=thread_func)
    thread.daemon = True
    thread.start()
    
    # start the qtconsole app
    app = TerminalIPythonApp.instance()
    app.initialize(["qtconsole", "--existing", connection_file])
    app.start()
Exemple #20
0
def _launch_qt_console(ppid, connection_file):
    """called as a new process"""
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp
    import threading
    import psutil
    import time

    # start a thread to kill this process when the parent process exits
    def thread_func():
        while True:
            if not psutil.pid_exists(ppid):
                os._exit(1)
            time.sleep(5)

    thread = threading.Thread(target=thread_func)
    thread.daemon = True
    thread.start()

    # start the qtconsole app
    app = TerminalIPythonApp.instance()
    app.initialize(["qtconsole", "--existing", connection_file])
    app.start()
Exemple #21
0
 def command(self, **options):
     from IPython.frontend.terminal.ipapp import TerminalIPythonApp
     app = TerminalIPythonApp.instance()
     app.initialize(argv=[])
     app.start()
Exemple #22
0
 def _ipython_pre_10(self):  # pragma: no cover
     from IPython.frontend.terminal.ipapp import TerminalIPythonApp
     app = TerminalIPythonApp.instance()
     app.initialize(argv=[])
     app.shell.user_ns.update(self.locals)
     app.start()
Exemple #23
0
 def _ipython_pre_100(self):
     """Start IPython pre-1.0.0"""
     from IPython.frontend.terminal.ipapp import TerminalIPythonApp
     app = TerminalIPythonApp.instance()
     app.initialize(argv=[])
     app.start()
Exemple #24
0
    def ipython(self, project, args, unknown_args):
        from IPython.frontend.terminal.ipapp import TerminalIPythonApp  # pylint: disable-msg=F0401

        app = TerminalIPythonApp.instance()
        app.initialize(argv=[])
        app.start()
Exemple #25
0
def ipython():
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp
    app = TerminalIPythonApp.instance()
    app.initialize(argv=[])
    app.shell.user_ns.update(_get_locals())
    app.start()
Exemple #26
0
def ipython():
    from IPython.frontend.terminal.ipapp import TerminalIPythonApp
    app = TerminalIPythonApp.instance()
    app.initialize(argv=[])
    app.shell.user_ns.update(_get_locals())
    app.start()
Exemple #27
0
        print str(recommended)

    user_ns = user_ns or {}
    try:
        user_ns.update(get_args(sys.argv))
    except exception.SpockException, e:
        print e.message
        print 'Starting normal IPython console'
    except KeyboardInterrupt:
        print "\nUser pressed Ctrl+C. Exiting..."
        sys.exit()
    except Exception, e:
        print 'spock exited with an unmanaged exception: %s' % str(e)
        sys.exit(-2)

    app = TerminalIPythonApp.instance()
    app.initialize()
    #config = get_config()
    return app


def mainloop(app=None, user_ns=None):
    if app is None:
        app = start(user_ns)
    app.start()


def prepare_input_handler():
    # initialize input handler as soon as possible
    import sardana.spock.inputhandler
    _ = sardana.spock.inputhandler.InputHandler()
import os
Exemple #29
0
    def command(self, **options):
        from IPython.frontend.terminal.ipapp import TerminalIPythonApp

        app = TerminalIPythonApp.instance()
        app.initialize(argv=[])
        app.start()
Exemple #30
0
        print str(recommended)

    user_ns = user_ns or {}
    try:
        user_ns.update(get_args(sys.argv))
    except exception.SpockException, e:
        print e.message
        print 'Starting normal IPython console'
    except KeyboardInterrupt:
        print "\nUser pressed Ctrl+C. Exiting..."
        sys.exit()
    except Exception, e:
        print 'spock exited with an unmanaged exception: %s' % str(e)
        sys.exit(-2)

    app = TerminalIPythonApp.instance()
    app.initialize()
    #config = get_config()
    return app

def mainloop(app=None, user_ns=None):
    if app is None:
        app = start(user_ns)
    app.start()

def prepare_input_handler():
    # initialize input handler as soon as possible
    import sardana.spock.inputhandler
    _ = sardana.spock.inputhandler.InputHandler()