Devuan deployment of britney2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
672 B

  1. import code
  2. class SubInterpreterExit(SystemExit):
  3. pass
  4. def console_quit():
  5. raise SubInterpreterExit()
  6. def run_python_console(britney_obj):
  7. console_locals = {
  8. 'britney': britney_obj,
  9. '__name__': '__console__',
  10. '__doc__': None,
  11. 'quit': console_quit,
  12. 'exit': console_quit,
  13. }
  14. console = code.InteractiveConsole(locals=console_locals)
  15. banner = """\
  16. Interactive python (REPL) shell in britney.
  17. Locals available
  18. * britney: Instance of the Britney object.
  19. * quit()/exit(): leave this REPL console.
  20. """
  21. try:
  22. console.interact(banner=banner, exitmsg='')
  23. except SubInterpreterExit:
  24. pass