Merge lp:~andrea-crotti-0/mailman/py_interactive into lp:mailman

Proposed by Andrea Crotti
Status: Merged
Approved by: Barry Warsaw
Approved revision: 7105
Merged at revision: 7107
Proposed branch: lp:~andrea-crotti-0/mailman/py_interactive
Merge into: lp:mailman
Diff against target: 90 lines (+40/-3)
3 files modified
src/mailman/commands/cli_withlist.py (+27/-1)
src/mailman/config/schema.cfg (+11/-0)
src/mailman/interact.py (+2/-2)
To merge this branch: bzr merge lp:~andrea-crotti-0/mailman/py_interactive
Reviewer Review Type Date Requested Status
Barry Warsaw code Approve
Review via email: mp+97125@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :

Great branch, thanks! After face-to-face review, we came up with a few minor things to fix. When you push the update, I'll merge this into trunk.

review: Approve (code)
7106. By Andrea Crotti

various small fixes after reviewing with Barry Warsaw

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mailman/commands/cli_withlist.py'
2--- src/mailman/commands/cli_withlist.py 2012-01-01 19:14:46 +0000
3+++ src/mailman/commands/cli_withlist.py 2012-03-13 04:37:19 +0000
4@@ -27,7 +27,9 @@
5
6
7 import re
8+import sys
9
10+from lazr.config import as_boolean
11 from zope.component import getUtility
12 from zope.interface import implements
13
14@@ -149,7 +151,31 @@
15 abort=config.db.abort,
16 config=config,
17 )
18- interact(upframe=False, banner=banner, overrides=overrides)
19+
20+ banner = config.shell.banner + '\n' + banner
21+ if as_boolean(config.shell.use_ipython):
22+ self._start_ipython(overrides, banner)
23+ else:
24+ self._start_python(overrides, banner)
25+
26+ def _start_ipython(self, overrides, banner):
27+ try:
28+ from IPython.frontend.terminal.embed import InteractiveShellEmbed
29+ ipshell = InteractiveShellEmbed(banner1=banner, user_ns=overrides)
30+ ipshell()
31+ except ImportError:
32+ print _('ipython is not available, set use_ipython to no')
33+
34+ def _start_python(self, overrides, banner):
35+ # set the tab completion
36+ try:
37+ import readline, rlcompleter
38+ readline.parse_and_bind('tab: complete')
39+ except ImportError:
40+ pass
41+ else:
42+ sys.ps1 = config.shell.ps1 + ' '
43+ interact(upframe=False, banner=banner, overrides=overrides)
44
45 def _details(self):
46 """Print detailed usage."""
47
48=== modified file 'src/mailman/config/schema.cfg'
49--- src/mailman/config/schema.cfg 2012-03-03 18:40:16 +0000
50+++ src/mailman/config/schema.cfg 2012-03-13 04:37:19 +0000
51@@ -62,6 +62,17 @@
52 # Which paths.* file system layout to use.
53 layout: dev
54
55+[shell]
56+
57+# customize the interpreter prompt
58+ps1: << MM >>
59+
60+# Banner to show on startup.
61+banner: welcome to the GNU Mailman shell
62+
63+# If IPython is found use it as the shell
64+use_ipython: no
65+
66
67 [paths.master]
68 # Important directories for Mailman operation. These are defined here so that
69
70=== modified file 'src/mailman/interact.py'
71--- src/mailman/interact.py 2012-01-01 19:14:46 +0000
72+++ src/mailman/interact.py 2012-03-13 04:37:19 +0000
73@@ -28,7 +28,7 @@
74 import sys
75 import code
76
77-DEFAULT_BANNER = object()
78+DEFAULT_BANNER = ''
79
80
81
82
83@@ -69,7 +69,7 @@
84 except:
85 pass
86 # We don't want the funky console object in parentheses in the banner.
87- if banner is DEFAULT_BANNER:
88+ if banner == DEFAULT_BANNER:
89 banner = '''\
90 Python %s on %s
91 Type "help", "copyright", "credits" or "license" for more information.''' % (