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
=== modified file 'src/mailman/commands/cli_withlist.py'
--- src/mailman/commands/cli_withlist.py 2012-01-01 19:14:46 +0000
+++ src/mailman/commands/cli_withlist.py 2012-03-13 04:37:19 +0000
@@ -27,7 +27,9 @@
2727
2828
29import re29import re
30import sys
3031
32from lazr.config import as_boolean
31from zope.component import getUtility33from zope.component import getUtility
32from zope.interface import implements34from zope.interface import implements
3335
@@ -149,7 +151,31 @@
149 abort=config.db.abort,151 abort=config.db.abort,
150 config=config,152 config=config,
151 )153 )
152 interact(upframe=False, banner=banner, overrides=overrides)154
155 banner = config.shell.banner + '\n' + banner
156 if as_boolean(config.shell.use_ipython):
157 self._start_ipython(overrides, banner)
158 else:
159 self._start_python(overrides, banner)
160
161 def _start_ipython(self, overrides, banner):
162 try:
163 from IPython.frontend.terminal.embed import InteractiveShellEmbed
164 ipshell = InteractiveShellEmbed(banner1=banner, user_ns=overrides)
165 ipshell()
166 except ImportError:
167 print _('ipython is not available, set use_ipython to no')
168
169 def _start_python(self, overrides, banner):
170 # set the tab completion
171 try:
172 import readline, rlcompleter
173 readline.parse_and_bind('tab: complete')
174 except ImportError:
175 pass
176 else:
177 sys.ps1 = config.shell.ps1 + ' '
178 interact(upframe=False, banner=banner, overrides=overrides)
153179
154 def _details(self):180 def _details(self):
155 """Print detailed usage."""181 """Print detailed usage."""
156182
=== modified file 'src/mailman/config/schema.cfg'
--- src/mailman/config/schema.cfg 2012-03-03 18:40:16 +0000
+++ src/mailman/config/schema.cfg 2012-03-13 04:37:19 +0000
@@ -62,6 +62,17 @@
62# Which paths.* file system layout to use.62# Which paths.* file system layout to use.
63layout: dev63layout: dev
6464
65[shell]
66
67# customize the interpreter prompt
68ps1: << MM >>
69
70# Banner to show on startup.
71banner: welcome to the GNU Mailman shell
72
73# If IPython is found use it as the shell
74use_ipython: no
75
6576
66[paths.master]77[paths.master]
67# Important directories for Mailman operation. These are defined here so that78# Important directories for Mailman operation. These are defined here so that
6879
=== modified file 'src/mailman/interact.py'
--- src/mailman/interact.py 2012-01-01 19:14:46 +0000
+++ src/mailman/interact.py 2012-03-13 04:37:19 +0000
@@ -28,7 +28,7 @@
28import sys28import sys
29import code29import code
3030
31DEFAULT_BANNER = object()31DEFAULT_BANNER = ''
3232
3333
3434
3535
@@ -69,7 +69,7 @@
69 except:69 except:
70 pass70 pass
71 # We don't want the funky console object in parentheses in the banner.71 # We don't want the funky console object in parentheses in the banner.
72 if banner is DEFAULT_BANNER:72 if banner == DEFAULT_BANNER:
73 banner = '''\73 banner = '''\
74Python %s on %s74Python %s on %s
75Type "help", "copyright", "credits" or "license" for more information.''' % (75Type "help", "copyright", "credits" or "license" for more information.''' % (