예제 #1
0
def interactive_console(mainmodule=None, quiet=False, future_flags=0):
    # set sys.{ps1,ps2} just before invoking the interactive interpreter. This
    # mimics what CPython does in pythonrun.c
    if not hasattr(sys, 'ps1'):
        sys.ps1 = '>>>> '
    if not hasattr(sys, 'ps2'):
        sys.ps2 = '.... '
    #
#    if not quiet:
#        try:
#            from _pypy_irc_topic import some_topic
#            text = "%s: ``%s''" % ( irc_header, some_topic())
#            while len(text) >= 80:
#                i = text[:80].rfind(' ')
#                print(text[:i])
#                text = text[i+1:]
#            print(text)
#        except ImportError:
#            pass
    #
    try:
        if not os.isatty(sys.stdin.fileno()):
            # Bail out if stdin is not tty-like, as pyrepl wouldn't be happy
            # For example, with:
            # subprocess.Popen(['pypy', '-i'], stdin=subprocess.PIPE)
            raise ImportError
        from pyrepl.simple_interact import check
        if not check():
            raise ImportError
        from pyrepl.simple_interact import run_multiline_interactive_console
    except ImportError:
        run_simple_interactive_console(mainmodule, future_flags=future_flags)
    else:
        run_multiline_interactive_console(mainmodule, future_flags=future_flags)
예제 #2
0
def interactive_console(mainmodule=None):
    # set sys.{ps1,ps2} just before invoking the interactive interpreter. This
    # mimics what CPython does in pythonrun.c
    if not hasattr(sys, 'ps1'):
        sys.ps1 = '>>>> '
    if not hasattr(sys, 'ps2'):
        sys.ps2 = '.... '
    #
    try:
        from _pypy_irc_topic import some_topic
        text = "And now for something completely different: ``%s''" % (
            some_topic(),)
        while len(text) >= 80:
            i = text[:80].rfind(' ')
            print text[:i]
            text = text[i+1:]
        print text
    except ImportError:
        pass
    #
    try:
        if not os.isatty(sys.stdin.fileno()):
            # Bail out if stdin is not tty-like, as pyrepl wouldn't be happy
            # For example, with:
            # subprocess.Popen(['pypy', '-i'], stdin=subprocess.PIPE)
            raise ImportError
        from pyrepl.simple_interact import check
        if not check():
            raise ImportError
        from pyrepl.simple_interact import run_multiline_interactive_console
    except ImportError:
        run_simple_interactive_console(mainmodule)
    else:
        run_multiline_interactive_console(mainmodule)
예제 #3
0
def interactive_console(mainmodule=None, quiet=False):
    # set sys.{ps1,ps2} just before invoking the interactive interpreter. This
    # mimics what CPython does in pythonrun.c
    if not hasattr(sys, 'ps1'):
        sys.ps1 = '>>>> '
    if not hasattr(sys, 'ps2'):
        sys.ps2 = '.... '
    #
    if not quiet:
        try:
            from _pypy_irc_topic import some_topic
            text = "And now for something completely different: ``%s''" % (
                some_topic(), )
            while len(text) >= 80:
                i = text[:80].rfind(' ')
                print(text[:i])
                text = text[i + 1:]
            print(text)
        except ImportError:
            pass
    #
    try:
        if not os.isatty(sys.stdin.fileno()):
            # Bail out if stdin is not tty-like, as pyrepl wouldn't be happy
            # For example, with:
            # subprocess.Popen(['pypy', '-i'], stdin=subprocess.PIPE)
            raise ImportError
        from pyrepl.simple_interact import check
        if not check():
            raise ImportError
        from pyrepl.simple_interact import run_multiline_interactive_console
    except ImportError:
        run_simple_interactive_console(mainmodule)
    else:
        run_multiline_interactive_console(mainmodule)
예제 #4
0
def interactive_console(mainmodule=None):
    try:
        from _pypy_irc_topic import some_topic
        text = "And now for something completely different: ``%s''" % (
            some_topic(), )
        while len(text) >= 80:
            i = text[:80].rfind(' ')
            print text[:i]
            text = text[i + 1:]
        print text
    except ImportError:
        pass
    try:
        from pyrepl.simple_interact import check
        if not check():
            raise ImportError
        from pyrepl.simple_interact import run_multiline_interactive_console
    except ImportError:
        run_simple_interactive_console(mainmodule)
    else:
        run_multiline_interactive_console(mainmodule)
예제 #5
0
def interactive_console(mainmodule=None):
    try:
        from _pypy_irc_topic import some_topic
        text = "And now for something completely different: ``%s''" % (
            some_topic(),)
        while len(text) >= 80:
            i = text[:80].rfind(' ')
            print text[:i]
            text = text[i+1:]
        print text
    except ImportError:
        pass
    try:
        from pyrepl.simple_interact import check
        if not check():
            raise ImportError
        from pyrepl.simple_interact import run_multiline_interactive_console
    except ImportError:
        run_simple_interactive_console(mainmodule)
    else:
        run_multiline_interactive_console(mainmodule)
예제 #6
0
def interactive_console(mainmodule=None, quiet=False):
    # set sys.{ps1,ps2} just before invoking the interactive interpreter. This
    # mimics what CPython does in pythonrun.c
    if not hasattr(sys, 'ps1'):
        sys.ps1 = '>>>> '
    if not hasattr(sys, 'ps2'):
        sys.ps2 = '.... '
    #
    if not quiet:
        try:
            from _pypy_irc_topic import some_topic
            text = "%s: ``%s''" % ( irc_header, some_topic())
            while len(text) >= 80:
                i = text[:80].rfind(' ')
                print(text[:i])
                text = text[i+1:]
            print(text)
        except ImportError:
            pass
    #
    run_interactive = run_simple_interactive_console
    try:
        if not os.isatty(sys.stdin.fileno()):
            # Bail out if stdin is not tty-like, as pyrepl wouldn't be happy
            # For example, with:
            # subprocess.Popen(['pypy', '-i'], stdin=subprocess.PIPE)
            raise ImportError
        from pyrepl.simple_interact import check
        if not check():
            raise ImportError
        from pyrepl.simple_interact import run_multiline_interactive_console
        run_interactive = run_multiline_interactive_console
    except ImportError:
        pass
    except SyntaxError:
        print("Warning: 'import pyrepl' failed with SyntaxError")
    run_interactive(mainmodule)