Ejemplo n.º 1
0
def interactive(idx=0, DongleClass=RfCat, intro=''):
    global d
    import rflib.chipcon_nic as rfnic
    import atexit

    d = DongleClass(idx=idx)
    d.setModeRX()  # this puts the dongle into receive mode
    atexit.register(cleanupInteractiveAtExit)

    gbls = globals()
    lcls = locals()

    try:
        import IPython.Shell
        ipsh = IPython.Shell.IPShell(argv=[''],
                                     user_ns=lcls,
                                     user_global_ns=gbls)
        print intro
        ipsh.mainloop(intro)

    except ImportError, e:
        try:
            from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
            ipsh = TerminalInteractiveShell()
            ipsh.user_global_ns.update(gbls)
            ipsh.user_global_ns.update(lcls)
            ipsh.autocall = 2  # don't require parenthesis around *everything*.  be smart!
            ipsh.mainloop(intro)
        except ImportError, e:
            print e
            shell = code.InteractiveConsole(gbls)
            shell.interact(intro)
Ejemplo n.º 2
0
def interactive(idx=0, DongleClass=RfCat, intro=''):
    global d
    import rflib.chipcon_nic as rfnic
    import atexit

    d = DongleClass(idx=idx)
    d.setModeRX()       # this puts the dongle into receive mode
    atexit.register(cleanupInteractiveAtExit)

    gbls = globals()
    lcls = locals()

    try:
        import IPython.Shell
        ipsh = IPython.Shell.IPShell(argv=[''], user_ns=lcls, user_global_ns=gbls)
        print intro
        ipsh.mainloop(intro)

    except ImportError, e:
        try:
            from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
            ipsh = TerminalInteractiveShell()
            ipsh.user_global_ns.update(gbls)
            ipsh.user_global_ns.update(lcls)
            ipsh.autocall = 2       # don't require parenthesis around *everything*.  be smart!
            ipsh.mainloop(intro)
        except ImportError, e:
            print e
            shell = code.InteractiveConsole(gbls)
            shell.interact(intro)
Ejemplo n.º 3
0
    def handle(self, *args, **kwargs):
        imported_objects = {
            'config' : self.config,
        }
        try:
            # Try IPython imports
            from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
            from IPython.config.loader import Config

            cfg = Config()
            shell = TerminalInteractiveShell(config=cfg, user_ns=imported_objects)
            shell.mainloop(display_banner='\n  Samovar  \n')
        except:
            import code
            code.InteractiveConsole(locals=imported_objects).interact()
Ejemplo n.º 4
0
    def handle(self, *args, **kwargs):
        imported_objects = {
            'config': self.config,
        }
        try:
            # Try IPython imports
            from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
            from IPython.config.loader import Config

            cfg = Config()
            shell = TerminalInteractiveShell(config=cfg,
                                             user_ns=imported_objects)
            shell.mainloop(display_banner='\n  Samovar  \n')
        except:
            import code
            code.InteractiveConsole(locals=imported_objects).interact()
Ejemplo n.º 5
0
def debug():
    from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
    shell = TerminalInteractiveShell(user_ns=vars())
    shell.mainloop()
Ejemplo n.º 6
0
def autoipython(funcs):
    # Use IPython in combination with AUTO
    # First import the shell class
    ipython11 = False
    try:
        import IPython.Shell
    except ImportError:
        try:  # Check for ipython >= 0.11
            from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
            ipython11 = True
        except ImportError:
            print("Sorry, ipython is not available on this system.")
            return

    if ipython11:
        from IPython.config.loader import Config
        cfg = Config()
        cfg.PromptManager.in_template = "AUTO In [\\#]: "
        cfg.PromptManager.in2_template = "AUTO    .\\D.: "
        cfg.PromptManager.out_template = "Out[\#]: "
        cfg.InteractiveShell.confirm_exit = False
        cfg.InteractiveShell.autocall = 2
        cfg.InteractiveShell.banner2 = """
Welcome to the AUTO IPython CLUI
man     -> List of AUTO CLUI commands"""

        ipshell = TerminalInteractiveShell(config=cfg, user_ns=funcs)
        ipshell.show_banner()
        ipshell.mainloop()
        return

    import IPython
    from IPython.iplib import InteractiveShell

    # Now create an instance of the embeddable shell. The first argument is a
    # string with options exactly as you would type them if you were starting
    # IPython at the system command line. Any parameters you want to define for
    # configuration can thus be specified here.

    args = [
        '-pi1', 'AUTO In [\\#]: ', '-pi2', 'AUTO    .\\D.: ', '-po',
        'Out[\#]: ', '-noconfirm_exit', '-autocall', '2'
    ]

    banner = [
        'Python %s\n'
        'Type "copyright", "credits" or "license" '
        'for more information.\n' % (sys.version.split('\n')[0], ),
        "IPython %s -- An enhanced Interactive Python." %
        (IPython.Release.version, ),
        """?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

Welcome to the AUTO IPython CLUI
man     -> List of AUTO CLUI commands"""
    ]

    class AUTOInteractiveShell(AUTOInteractive, InteractiveShell):
        def __init__(self, name, **kw):
            self.parentclass = InteractiveShell
            AUTOInteractive.__init__(self, kw["user_ns"], None)
            InteractiveShell.__init__(self, name, **kw)

        def prefilter(self, line, continue_prompt):
            if not continue_prompt:
                line = self.processShorthand(line)
            line = InteractiveShell.prefilter(self, line, continue_prompt)
            return line

    ipshell = IPython.Shell.IPShell(args,
                                    user_ns=funcs,
                                    user_global_ns=funcs,
                                    shell_class=AUTOInteractiveShell)
    ipshell.IP.user_ns['help'] = ipshell.IP.help
    ipshell.mainloop(banner='\n'.join(banner))
Ejemplo n.º 7
0
def debug():
    from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell

    shell = TerminalInteractiveShell(user_ns=vars())
    shell.mainloop()