Пример #1
0
def run_classic_shell(locals, globals, first_time):
    if first_time:
        banner = "Hit Ctrl-D to return to PuDB."
    else:
        banner = ""

    ns = SetPropagatingDict([locals, globals], locals)

    from pudb.settings import get_save_config_path
    from os.path import join
    hist_file = join(
            get_save_config_path(),
            "shell-history")

    if HAVE_READLINE:
        readline.set_completer(
                rlcompleter.Completer(ns).complete)
        readline.parse_and_bind("tab: complete")
        try:
            readline.read_history_file(hist_file)
        except IOError:
            pass

    from code import InteractiveConsole
    cons = InteractiveConsole(ns)

    cons.interact(banner)

    if HAVE_READLINE:
        readline.write_history_file(hist_file)
Пример #2
0
def setup_readline():
    import os
    import atexit

    from pudb.settings import get_save_config_path
    histfile = os.path.join(get_save_config_path(), "shell-history")

    if os.access(histfile, os.R_OK):
        readline.read_history_file(histfile)
    atexit.register(readline.write_history_file, histfile)
    readline.parse_and_bind("tab: complete")
Пример #3
0
def setup_readline():
    import os
    import atexit

    from pudb.settings import get_save_config_path
    histfile = os.path.join(
            get_save_config_path(),
            "shell-history")

    if os.access(histfile, os.R_OK):
        readline.read_history_file(histfile)
    atexit.register(readline.write_history_file, histfile)
    readline.parse_and_bind("tab: complete")
Пример #4
0
def setup_readline():
    import os
    import atexit

    from pudb.settings import get_save_config_path
    histfile = os.path.join(get_save_config_path(), "shell-history")

    try:
        readline.read_history_file(histfile)
        atexit.register(readline.write_history_file, histfile)
    except Exception:
        pass

    readline.parse_and_bind("tab: complete")
Пример #5
0
def setup_readline():
    import os
    import atexit

    from pudb.settings import get_save_config_path
    histfile = os.path.join(
            get_save_config_path(),
            "shell-history")

    try:
        readline.read_history_file(histfile)
        atexit.register(readline.write_history_file, histfile)
    except Exception:
        pass

    readline.parse_and_bind("tab: complete")
Пример #6
0
def setup_readline():
    import os
    import atexit

    from pudb.settings import get_save_config_path
    histfile = os.path.join(
            get_save_config_path(),
            "shell-history")

    try:
        readline.read_history_file(histfile)
        atexit.register(readline.write_history_file, histfile)
    except Exception:
        # http://docs.python.org/3/howto/pyporting.html#capturing-the-currently-raised-exception
        import sys
        e = sys.exc_info()[1]

        from warnings import warn
        warn("Error opening readline history file: %s" % e)

    readline.parse_and_bind("tab: complete")
Пример #7
0
def run_classic_shell(globals, locals, first_time=[True]):
    if first_time:
        banner = "Hit Ctrl-D to return to PuDB."
        first_time.pop()
    else:
        banner = ""

    ns = SetPropagatingDict([locals, globals], locals)

    from pudb.settings import get_save_config_path
    from os.path import join
    hist_file = join(
            get_save_config_path(),
            "shell-history")

    try:
        import readline
        import rlcompleter
        have_readline = True
    except ImportError:
        have_readline = False

    if have_readline:
        readline.set_completer(
                rlcompleter.Completer(ns).complete)
        readline.parse_and_bind("tab: complete")
        readline.clear_history()
        try:
            readline.read_history_file(hist_file)
        except OSError:
            pass

    from code import InteractiveConsole
    cons = InteractiveConsole(ns)

    cons.interact(banner)

    if have_readline:
        readline.write_history_file(hist_file)