diff options
| author | Barry Warsaw | 2012-03-12 22:01:58 -0700 |
|---|---|---|
| committer | Barry Warsaw | 2012-03-12 22:01:58 -0700 |
| commit | b725360062b08a422f337b272bdbb56b7a41f51d (patch) | |
| tree | 32774958effa98f2b52e13bae84e814639f49ec8 /src/mailman/commands/cli_withlist.py | |
| parent | 5f69c4e7c9ee532065e4c19a862f915b2178d482 (diff) | |
| parent | f66b5879531dc37509402cc17c1e7bfe817d964c (diff) | |
| download | mailman-b725360062b08a422f337b272bdbb56b7a41f51d.tar.gz mailman-b725360062b08a422f337b272bdbb56b7a41f51d.tar.zst mailman-b725360062b08a422f337b272bdbb56b7a41f51d.zip | |
Diffstat (limited to 'src/mailman/commands/cli_withlist.py')
| -rw-r--r-- | src/mailman/commands/cli_withlist.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/mailman/commands/cli_withlist.py b/src/mailman/commands/cli_withlist.py index 61e1bec7c..7bf7c4384 100644 --- a/src/mailman/commands/cli_withlist.py +++ b/src/mailman/commands/cli_withlist.py @@ -27,7 +27,9 @@ __all__ = [ import re +import sys +from lazr.config import as_boolean from zope.component import getUtility from zope.interface import implements @@ -149,7 +151,30 @@ class Withlist: abort=config.db.abort, config=config, ) - interact(upframe=False, banner=banner, overrides=overrides) + banner = config.shell.banner + '\n' + banner + if as_boolean(config.shell.use_ipython): + self._start_ipython(overrides, banner) + else: + self._start_python(overrides, banner) + + def _start_ipython(self, overrides, banner): + try: + from IPython.frontend.terminal.embed import InteractiveShellEmbed + ipshell = InteractiveShellEmbed(banner1=banner, user_ns=overrides) + ipshell() + except ImportError: + print _('ipython is not available, set use_ipython to no') + + def _start_python(self, overrides, banner): + # Set the tab completion. + try: + import readline, rlcompleter + readline.parse_and_bind('tab: complete') + except ImportError: + pass + else: + sys.ps1 = config.shell.prompt + ' ' + interact(upframe=False, banner=banner, overrides=overrides) def _details(self): """Print detailed usage.""" @@ -214,9 +239,9 @@ and run this from the command line: % bin/mailman withlist -r change mylist@example.com 'My List'""") - + class Shell(Withlist): """An alias for `withlist`.""" - + name = 'shell' |
