summaryrefslogtreecommitdiff
path: root/src/mailman/commands/cli_withlist.py
diff options
context:
space:
mode:
authortoshio2012-03-14 05:30:52 +0000
committertoshio2012-03-14 05:30:52 +0000
commitd1a9979ecf35d05ed115651dcc6b8680af08b954 (patch)
treecde5caa9a9c20467b4cb3768b564d08e6a368b1a /src/mailman/commands/cli_withlist.py
parentccde42a936f6c87032c7afd80f33ca5f3fa00b54 (diff)
parentbcc42e2201c7172848185e5675a7b79e3d28aa0f (diff)
downloadmailman-d1a9979ecf35d05ed115651dcc6b8680af08b954.tar.gz
mailman-d1a9979ecf35d05ed115651dcc6b8680af08b954.tar.zst
mailman-d1a9979ecf35d05ed115651dcc6b8680af08b954.zip
Diffstat (limited to 'src/mailman/commands/cli_withlist.py')
-rw-r--r--src/mailman/commands/cli_withlist.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/mailman/commands/cli_withlist.py b/src/mailman/commands/cli_withlist.py
index 61e1bec7c..3b1b36b1a 100644
--- a/src/mailman/commands/cli_withlist.py
+++ b/src/mailman/commands/cli_withlist.py
@@ -27,15 +27,17 @@ __all__ = [
import re
+import sys
+from lazr.config import as_boolean
from zope.component import getUtility
from zope.interface import implements
from mailman.config import config
from mailman.core.i18n import _
-from mailman.interact import DEFAULT_BANNER, interact
from mailman.interfaces.command import ICLISubCommand
from mailman.interfaces.listmanager import IListManager
+from mailman.utilities.interact import DEFAULT_BANNER, interact
from mailman.utilities.modules import call_name
# Global holding onto the open mailing list.
@@ -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'