Example #1
0
def setup_shell():

    banner = '+----------------------------------------------------------------+\n'
    banner += ' APSG '
    banner += APSG_VERSION
    banner += ' [interactive shell] - http://ondrolexa.github.io/apsg\n'
    banner += '+----------------------------------------------------------------+\n'
    banner += '\n'
    banner += 'Commands: \n'
    banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
    banner += '\t"clear" to clear the shell screen\n'
    banner += '\n'
    banner += 'Documentation:\n'
    banner += '\thelp(Fol), ?Fol, Fol?, or Fol()? all do the same\n'
    banner += '\t"docs" will launch webbrowser showing documentation'
    banner += '\n'
    exit_msg = '\n... [Exiting the APSG interactive shell] ...\n'

    try:
        import IPython
    except:
        raise("ERROR: IPython Failed to load")

    try:
        from IPython.config.loader import Config
        from IPython.terminal.embed import InteractiveShellEmbed

        cfg = Config()
        cfg.PromptManager.in_template = "APSG:\\#> "
        cfg.PromptManager.out_template = "APSG:\\#: "
        apsgShell = InteractiveShellEmbed(config=cfg, banner1=banner, exit_msg = exit_msg)
        apsgShell.define_magic("clear", magic_clear)
        #apsgShell.define_magic("docs", magic_docs)

    except ImportError:
        try:
            from IPython.Shell import IPShellEmbed
            argsv = ['-pi1','APSG:\\#>','-pi2','   .\\D.:','-po','APSG:\\#>','-nosep']

            apsgShell = IPShellEmbed(argsv)
            apsgShell.set_banner(banner)
            apsgShell.set_exit_msg(exit_msg)
            apsgShell.IP.api.expose_magic("clear", magic_clear)
        except ImportError:
            raise

    return apsgShell
Example #2
0
def setup_shell():

    banner = '+-----------------------------------------------------------+\n'
    banner += ' APSG '
    banner += APSG_VERSION
    banner += ' [interactive shell] - http://ondrolexa.github.io/apsg\n'
    banner += '+-----------------------------------------------------------+\n'
    banner += '\n'
    banner += 'Commands: \n'
    banner += '\t"exit()" or press "Ctrl+ D" to exit the shell\n'
    banner += '\t"clear" to clear the shell screen\n'
    banner += '\n'
    banner += 'Documentation:\n'
    banner += '\thelp(Fol), ?Fol, Fol?, or Fol()? all do the same\n'
    banner += '\t"docs" will launch webbrowser showing documentation'
    banner += '\n'
    exit_msg = '\n... [Exiting the APSG interactive shell] ...\n'

    try:
        from traitlets.config import Config
        from IPython.terminal.embed import InteractiveShellEmbed

        cfg = Config()
        cfg.PromptManager.in_template = "APSG:\\#> "
        cfg.PromptManager.out_template = "APSG:\\#: "
        apsgShell = InteractiveShellEmbed(config=cfg, banner1=banner,
                                          exit_msg = exit_msg)
        apsgShell.define_magic("clear", magic_clear)
        #apsgShell.define_magic("docs", magic_docs)

    except ImportError:
        try:
            from IPython.Shell import IPShellEmbed
            argsv = ['-pi1','APSG:\\#>','-pi2','   .\\D.:','-po','APSG:\\#>','-nosep']

            apsgShell = IPShellEmbed(argsv)
            apsgShell.set_banner(banner)
            apsgShell.set_exit_msg(exit_msg)
            apsgShell.IP.api.expose_magic("clear", magic_clear)
        except ImportError:
            raise("ERROR: IPython shell failed to load")

    return apsgShell
Example #3
0
def setup_ipython():
    try:
        import IPython
        from IPython.config.loader import Config
        from IPython.terminal.embed import InteractiveShellEmbed

        cfg = Config()
        cfg.PromptManager.in_template = "MyCV:\\#> "
        cfg.PromptManager.out_template = "MyCV:\\#: "
        #~ cfg.InteractiveShellEmbed.prompt_in1 = "MyCV:\\#> "
        #~ cfg.InteractiveShellEmbed.prompt_out="MyCV:\\#: "
        scvShell = InteractiveShellEmbed(config=cfg,
                                         banner1=banner,
                                         exit_msg=exit_msg)
        scvShell.define_magic("tutorial", magic_tutorial)
        scvShell.define_magic("clear", magic_clear)
        scvShell.define_magic("example", magic_examples)
        scvShell.define_magic("forums", magic_forums)
        scvShell.define_magic("walkthrough", magic_walkthrough)
        scvShell.define_magic("docs", magic_docs)
    except ImportError:
        try:
            from IPython.Shell import IPShellEmbed

            argsv = [
                '-pi1', 'MyCV:\\#>', '-pi2', '   .\\D.:', '-po', 'MyCV:\\#>',
                '-nosep'
            ]
            scvShell = IPShellEmbed(argsv)
            scvShell.set_banner(banner)
            scvShell.set_exit_msg(exit_msg)
            scvShell.IP.api.expose_magic("tutorial", magic_tutorial)
            scvShell.IP.api.expose_magic("clear", magic_clear)
            scvShell.IP.api.expose_magic("example", magic_examples)
            scvShell.IP.api.expose_magic("forums", magic_forums)
            scvShell.IP.api.expose_magic("walkthrough", magic_walkthrough)
            scvShell.IP.api.expose_magic("docs", magic_docs)
        except ImportError:
            raise

    return scvShell()
Example #4
0
def setup_ipython():
    try:
        import IPython
        from IPython.config.loader import Config
        from IPython.terminal.embed import InteractiveShellEmbed

        cfg = Config()
        cfg.PromptManager.in_template = "SimpleCV:\\#> "
        cfg.PromptManager.out_template = "SimpleCV:\\#: "
        #~ cfg.InteractiveShellEmbed.prompt_in1 = "SimpleCV:\\#> "
        #~ cfg.InteractiveShellEmbed.prompt_out="SimpleCV:\\#: "
        scvShell = InteractiveShellEmbed(config=cfg, banner1=banner,
                                         exit_msg=exit_msg)
        scvShell.define_magic("tutorial", magic_tutorial)
        scvShell.define_magic("clear", magic_clear)
        scvShell.define_magic("example", magic_examples)
        scvShell.define_magic("forums", magic_forums)
        scvShell.define_magic("walkthrough", magic_walkthrough)
        scvShell.define_magic("docs", magic_docs)
    except ImportError:
        try:
            from IPython.Shell import IPShellEmbed

            argsv = ['-pi1', 'SimpleCV:\\#>', '-pi2', '   .\\D.:', '-po',
                     'SimpleCV:\\#>', '-nosep']
            scvShell = IPShellEmbed(argsv)
            scvShell.set_banner(banner)
            scvShell.set_exit_msg(exit_msg)
            scvShell.IP.api.expose_magic("tutorial", magic_tutorial)
            scvShell.IP.api.expose_magic("clear", magic_clear)
            scvShell.IP.api.expose_magic("example", magic_examples)
            scvShell.IP.api.expose_magic("forums", magic_forums)
            scvShell.IP.api.expose_magic("walkthrough", magic_walkthrough)
            scvShell.IP.api.expose_magic("docs", magic_docs)
        except ImportError:
            raise

    return scvShell()