'start the local python interpreter (for debugging purposes)'

def do_python(self, arg):

    orig_exit = builtins.exit
    orig_quit = builtins.quit
    def disabled_exit(*args, **kwargs):
        self.display_warning('exit()    disabled    !    use    ctrl+D    to    exit    the    python    shell')
    builtins.exit = disabled_exit
    builtins.quit = disabled_exit
    oldcompleter = readline.get_completer()
    try:
        local_ns = {'pupsrv': self.pupsrv}
        readline.set_completer(PythonCompleter(local_ns=local_ns).complete)
        readline.parse_and_bind('tab:    complete')
        code.interact(local=local_ns)
    except Exception as e:
        self.display_error(str(e))
    finally:
        readline.set_completer(oldcompleter)
        readline.parse_and_bind('tab:    complete')
        builtins.exit = orig_exit
        builtins.quit = orig_quit
