Merge lp:~sinzui/launchpad/discard-list-spam-0 into lp:launchpad

Proposed by Curtis Hovey on 2010-09-17
Status: Merged
Approved by: Brad Crittenden on 2010-09-17
Approved revision: no longer in the source branch.
Merged at revision: 11572
Proposed branch: lp:~sinzui/launchpad/discard-list-spam-0
Merge into: lp:launchpad
Diff against target: 448 lines (+59/-49)
16 files modified
buildmailman.py (+10/-10)
lib/canonical/launchpad/scripts/runlaunchpad.py (+12/-7)
lib/lp/scripts/utilities/killservice.py (+1/-1)
lib/lp/services/mailman/config/tests/test_config.py (+2/-5)
lib/lp/services/mailman/doc/basic-integration.txt (+1/-1)
lib/lp/services/mailman/doc/batching.txt (+1/-1)
lib/lp/services/mailman/doc/logging.txt (+4/-4)
lib/lp/services/mailman/doc/staging.txt (+3/-5)
lib/lp/services/mailman/monkeypatches/__init__.py (+3/-3)
lib/lp/services/mailman/monkeypatches/mm_cfg.py.in (+1/-1)
lib/lp/services/mailman/runmailman.py (+4/-4)
lib/lp/services/mailman/testing/layers.py (+1/-1)
lib/lp/services/mailman/testing/withlist_1.py (+1/-1)
lib/lp/services/mailman/testing/withlist_2.py (+2/-2)
scripts/mlist-sync.py (+1/-1)
utilities/launchpad-database-setup (+12/-2)
To merge this branch: bzr merge lp:~sinzui/launchpad/discard-list-spam-0
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code 2010-09-17 Approve on 2010-09-17
Review via email: mp+35885@code.launchpad.net

Description of the Change

This is my branch to move mailman from canonical.launchpad to lp.services

    lp:~sinzui/launchpad/discard-list-spam-0
    Diff size: 417
    Launchpad bug:
          https://bugs.launchpad.net/bugs/641526
    Test command: ./bin/test -vv --layer=Mailman (may need to run 3 times)
        ./bin/test -vv lp.services.mailman
    Pre-implementation: no one
    Target release: 10.10

Automatically discard messages that claim to be from the list
-------------------------------------------------------------

The mailman config and monekypatch rules can be moved to lp.services.mailman,
which is the only package that uses them. The monkeypatch tests are already
in lp.services.mailman.

This should be done before any monkeypatch work is needed.

Rules
-----

    * Move the remaining code into lp.services/mailman
    ADDENDUM
    * Fix the logging test because the LaunchapdErrorUtility changed in
      July
    * Fix the staging text because the cached property is not needed.

QA
--

    * On staging verify mail arrives to the archive
    * On staging verify mail goes in to the moderation queue.

Lint
----

Linting changed files:
  buildmailman.py
  lib/canonical/launchpad/scripts/runlaunchpad.py
  lib/lp/scripts/utilities/killservice.py
  lib/lp/services/mailman/runmailman.py
  lib/lp/services/mailman/config/tests/test_config.py
  lib/lp/services/mailman/doc/basic-integration.txt
  lib/lp/services/mailman/doc/batching.txt
  lib/lp/services/mailman/doc/logging.txt
  lib/lp/services/mailman/doc/staging.txt
  lib/lp/services/mailman/monkeypatches/__init__.py
  lib/lp/services/mailman/monkeypatches/mm_cfg.py.in
  lib/lp/services/mailman/testing/layers.py
  lib/lp/services/mailman/testing/withlist_1.py
  lib/lp/services/mailman/testing/withlist_2.py
  scripts/mlist-sync.py

Lint reports some issue in some modules about the imports, but the code
is correct for how we are building mailman

Test
----

Run the tests many times to see them pass. The layer is fatally plagues
by timeouts--the entire testing strategy needs to be rethought.

Implementation
--------------

No code changes.

To post a comment you must log in.
Brad Crittenden (bac) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'buildmailman.py'
2--- buildmailman.py 2010-04-27 19:48:39 +0000
3+++ buildmailman.py 2010-09-18 03:14:43 +0000
4@@ -13,9 +13,9 @@
5 import subprocess
6
7 from canonical.config import config
8-from canonical.launchpad.mailman.config import (
9+from lp.services.mailman.config import (
10 configure_prefix, configure_siteowner)
11-from canonical.launchpad.mailman.monkeypatches import monkey_patch
12+from lp.services.mailman.monkeypatches import monkey_patch
13 from lazr.config import as_username_groupname
14
15 basepath = [part for part in sys.path if part]
16@@ -42,9 +42,9 @@
17 return 0
18
19 # sys.path_importer_cache is a mapping of elements of sys.path to importer
20- # objects used to handle them. In Python2.5+ when an element of sys.path is
21- # found to not exist on disk, a NullImporter is created and cached - this
22- # causes Python to never bother re-inspecting the disk for that path
23+ # objects used to handle them. In Python2.5+ when an element of sys.path
24+ # is found to not exist on disk, a NullImporter is created and cached -
25+ # this causes Python to never bother re-inspecting the disk for that path
26 # element. We must clear that cache element so that our second attempt to
27 # import MailMan after building it will actually check the disk.
28 del sys.path_importer_cache[mailman_path]
29@@ -102,7 +102,7 @@
30 print >> sys.stderr, 'Could not configure Mailman:'
31 sys.exit(retcode)
32 # Make.
33- retcode = subprocess.call(('make',), cwd=mailman_source)
34+ retcode = subprocess.call(('make', ), cwd=mailman_source)
35 if retcode:
36 print >> sys.stderr, 'Could not make Mailman.'
37 sys.exit(retcode)
38@@ -116,8 +116,8 @@
39 # installation will call Mailman's ``bin/update``, which is a script
40 # that needs this fix.
41 build_dir = os.path.join(mailman_source, 'build')
42- original = '#! %s\n' % (executable,)
43- modified = '#! /usr/bin/env %s\n' % (executable,)
44+ original = '#! %s\n' % (executable, )
45+ modified = '#! /usr/bin/env %s\n' % (executable, )
46 for (dirpath, dirnames, filenames) in os.walk(build_dir):
47 for filename in filenames:
48 filename = os.path.join(dirpath, filename)
49@@ -191,7 +191,8 @@
50 def configure_site_list(mailman_bin, site_list_name):
51 """Configure the site list.
52
53- Currently, the only thing we want to set is to not advertise the site list.
54+ Currently, the only thing we want to set is to not advertise the
55+ site list.
56 """
57 fd, config_file_name = tempfile.mkstemp()
58 try:
59@@ -219,7 +220,6 @@
60 return build_mailman()
61
62
63-
64 if __name__ == '__main__':
65 return_code = main()
66 sys.exit(return_code)
67
68=== removed directory 'lib/canonical/launchpad/mailman'
69=== removed file 'lib/canonical/launchpad/mailman/__init__.py'
70=== removed directory 'lib/canonical/launchpad/mailman/doc'
71=== modified file 'lib/canonical/launchpad/scripts/runlaunchpad.py'
72--- lib/canonical/launchpad/scripts/runlaunchpad.py 2010-08-20 20:31:18 +0000
73+++ lib/canonical/launchpad/scripts/runlaunchpad.py 2010-09-18 03:14:43 +0000
74@@ -16,7 +16,7 @@
75 from zope.app.server.main import main
76
77 from canonical.config import config
78-from canonical.launchpad.mailman import runmailman
79+from lp.services.mailman import runmailman
80 from canonical.launchpad.testing import googletestservice
81 from canonical.lazr.pidfile import (
82 make_pidfile,
83@@ -32,6 +32,7 @@
84
85
86 class Service(object):
87+
88 @property
89 def should_launch(self):
90 """Return true if this service should be launched."""
91@@ -52,7 +53,8 @@
92 script.
93 :param section_name: The config section name that provides the
94 launch, logfile and spew options.
95- :param pre_launch: A callable that is called before the launch process.
96+ :param pre_launch: A callable that is called before the launch
97+ process.
98 """
99 # No point calling super's __init__.
100 # pylint: disable-msg=W0231
101@@ -119,6 +121,7 @@
102
103
104 class MailmanService(Service):
105+
106 @property
107 def should_launch(self):
108 return config.mailman.launch
109@@ -132,6 +135,7 @@
110
111
112 class CodebrowseService(Service):
113+
114 @property
115 def should_launch(self):
116 return False
117@@ -158,11 +162,11 @@
118
119 class MemcachedService(Service):
120 """A local memcached service for developer environments."""
121+
122 @property
123 def should_launch(self):
124 return config.memcached.launch
125
126-
127 def launch(self):
128 cmd = [
129 'memcached',
130@@ -187,6 +191,7 @@
131
132 :param process: An instance of subprocess.Popen.
133 """
134+
135 def stop_process():
136 if process.poll() is None:
137 os.kill(process.pid, signal.SIGTERM)
138@@ -227,10 +232,10 @@
139 """Split the given command-line arguments into services to start and Zope
140 arguments.
141
142- The runlaunchpad script can take an optional '-r services,...' argument. If
143- this argument is present, then the value is returned as the first element
144- of the return tuple. The rest of the arguments are returned as the second
145- element of the return tuple.
146+ The runlaunchpad script can take an optional '-r services,...' argument.
147+ If this argument is present, then the value is returned as the first
148+ element of the return tuple. The rest of the arguments are returned as the
149+ second element of the return tuple.
150
151 Returns a tuple of the form ([service_name, ...], remaining_argv).
152 """
153
154=== modified file 'lib/lp/scripts/utilities/killservice.py'
155--- lib/lp/scripts/utilities/killservice.py 2010-08-20 20:31:18 +0000
156+++ lib/lp/scripts/utilities/killservice.py 2010-09-18 03:14:43 +0000
157@@ -17,7 +17,7 @@
158 import time
159
160 from canonical.config import config
161-from canonical.launchpad.mailman.runmailman import stop_mailman
162+from lp.services.mailman.runmailman import stop_mailman
163 from canonical.launchpad.scripts import (
164 logger,
165 logger_options,
166
167=== renamed directory 'lib/canonical/launchpad/mailman/config' => 'lib/lp/services/mailman/config'
168=== modified file 'lib/lp/services/mailman/config/tests/test_config.py'
169--- lib/canonical/launchpad/mailman/config/tests/test_config.py 2010-08-20 20:31:18 +0000
170+++ lib/lp/services/mailman/config/tests/test_config.py 2010-09-18 03:14:43 +0000
171@@ -10,9 +10,6 @@
172
173 def test_suite():
174 suite = DocTestSuite(
175- 'canonical.launchpad.mailman.config',
176- optionflags=NORMALIZE_WHITESPACE | ELLIPSIS
177- )
178+ 'lp.services.mailman.config',
179+ optionflags=NORMALIZE_WHITESPACE | ELLIPSIS)
180 return suite
181-
182-
183
184=== modified file 'lib/lp/services/mailman/doc/basic-integration.txt'
185--- lib/lp/services/mailman/doc/basic-integration.txt 2009-09-24 20:14:42 +0000
186+++ lib/lp/services/mailman/doc/basic-integration.txt 2010-09-18 03:14:43 +0000
187@@ -9,7 +9,7 @@
188
189 >>> import subprocess, os
190 >>> from canonical.config import config
191- >>> from canonical.launchpad.mailman.config import configure_prefix
192+ >>> from lp.services.mailman.config import configure_prefix
193 >>> def withlist(callable, *options):
194 ... callable_path = 'lp.services.mailman.testing.' + callable
195 ... args = ' '.join(options)
196
197=== modified file 'lib/lp/services/mailman/doc/batching.txt'
198--- lib/lp/services/mailman/doc/batching.txt 2009-06-23 17:51:24 +0000
199+++ lib/lp/services/mailman/doc/batching.txt 2010-09-18 03:14:43 +0000
200@@ -18,7 +18,7 @@
201
202 Now we'll restart Mailman with a batch size of 1.
203
204- >>> from canonical.launchpad.mailman import runmailman
205+ >>> from lp.services.mailman import runmailman
206 >>> from canonical.testing.layers import LayerProcessController
207 >>> runmailman.stop_mailman(
208 ... quiet=True, config=LayerProcessController.appserver_config)
209
210=== modified file 'lib/lp/services/mailman/doc/logging.txt'
211--- lib/lp/services/mailman/doc/logging.txt 2009-09-24 18:51:29 +0000
212+++ lib/lp/services/mailman/doc/logging.txt 2010-09-18 03:14:43 +0000
213@@ -12,19 +12,19 @@
214 in the [mailman] section of config.
215
216 >>> from canonical.config import config
217- >>> from canonical.launchpad.mailman.monkeypatches.xmlrpcrunner import (
218+ >>> from lp.services.mailman.monkeypatches.xmlrpcrunner import (
219 ... MailmanErrorUtility)
220
221 >>> error_utility = MailmanErrorUtility()
222 >>> print error_utility._default_config_section
223 mailman
224
225- >>> print error_utility.prefix
226+ >>> print error_utility.oops_prefix
227 TMMX
228 >>> print config.mailman.oops_prefix
229 TMMX
230
231- >>> print error_utility.error_dir
232+ >>> print error_utility.log_namer._output_root
233 /var/tmp/mailman-xmlrpc.test
234 >>> print config.mailman.error_dir
235 /var/tmp/mailman-xmlrpc.test
236@@ -36,7 +36,7 @@
237 The log_exception() function is used by XMLRPCRunner to report known
238 exceptions. It reports the OOPS.
239
240- >>> from canonical.launchpad.mailman.monkeypatches.xmlrpcrunner import (
241+ >>> from lp.services.mailman.monkeypatches.xmlrpcrunner import (
242 ... log_exception)
243
244 >>> def test_log_exception():
245
246=== modified file 'lib/lp/services/mailman/doc/staging.txt'
247--- lib/lp/services/mailman/doc/staging.txt 2010-09-01 09:57:15 +0000
248+++ lib/lp/services/mailman/doc/staging.txt 2010-09-18 03:14:43 +0000
249@@ -30,10 +30,8 @@
250 >>> logout()
251
252 >>> from canonical.launchpad.testing.pages import setupBrowser
253- >>> from lp.services.propertycache import IPropertyCache
254 >>> browser = setupBrowser('Basic %s:%s' %
255- ... (IPropertyCache(owner).preferredemail.email,
256- ... owner._password_cleartext_cached))
257+ ... (owner.preferredemail.email, owner._password_cleartext_cached))
258
259 >>> from lp.services.mailman.testing import helpers
260 >>> helpers.apply_for_list(browser, 'staging-one')
261@@ -140,7 +138,7 @@
262 Now we need to simulate the difference between the staging and production
263 databases. To do this, we'll use a helper, but first we need to stop Mailman.
264
265- >>> from canonical.launchpad.mailman import runmailman
266+ >>> from lp.services.mailman import runmailman
267 >>> from canonical.testing.layers import LayerProcessController
268 >>> runmailman.stop_mailman(
269 ... quiet=True, config=LayerProcessController.appserver_config)
270@@ -194,7 +192,7 @@
271
272 >>> import os
273 >>> import sys
274- >>> from subprocess import *
275+ >>> from subprocess import Popen, PIPE
276 >>> proc = Popen(
277 ... ('scripts/mlist-sync.py', '--hostname',
278 ... 'lists.prod.launchpad.dev', sync_details.source_dir),
279
280=== renamed directory 'lib/canonical/launchpad/mailman/monkeypatches' => 'lib/lp/services/mailman/monkeypatches'
281=== modified file 'lib/lp/services/mailman/monkeypatches/__init__.py'
282--- lib/canonical/launchpad/mailman/monkeypatches/__init__.py 2009-09-24 20:14:42 +0000
283+++ lib/lp/services/mailman/monkeypatches/__init__.py 2010-09-18 03:14:43 +0000
284@@ -37,7 +37,7 @@
285 # Calculate the parent directory of the canonical package. This directory
286 # will get appended to Mailman's sys.path.
287 import canonical
288- from canonical.launchpad.mailman.config import configure_siteowner
289+ from lp.services.mailman.config import configure_siteowner
290 launchpad_top = os.path.dirname(
291 os.path.dirname(os.path.dirname(canonical.__file__)))
292 # Read the email footer template for all Launchpad messages.
293@@ -88,7 +88,7 @@
294 runner_file = open(runner_path, 'w')
295 try:
296 print >> runner_file, (
297- 'from canonical.launchpad.mailman.monkeypatches.xmlrpcrunner '
298+ 'from lp.services.mailman.monkeypatches.xmlrpcrunner '
299 'import *')
300 finally:
301 runner_file.close()
302@@ -104,7 +104,7 @@
303 mailman_path, 'Mailman', 'Handlers', mm_name + '.py')
304 handler_file = open(handler_path, 'w')
305 try:
306- package = 'canonical.launchpad.mailman.monkeypatches'
307+ package = 'lp.services.mailman.monkeypatches'
308 module = package + '.' + lp_name
309 print >> handler_file, 'from', module, 'import *'
310 finally:
311
312=== modified file 'lib/lp/services/mailman/monkeypatches/mm_cfg.py.in'
313--- lib/canonical/launchpad/mailman/monkeypatches/mm_cfg.py.in 2009-09-24 20:10:01 +0000
314+++ lib/lp/services/mailman/monkeypatches/mm_cfg.py.in 2010-09-18 03:14:43 +0000
315@@ -17,7 +17,7 @@
316
317 # Pick up Launchpad static overrides. This will also pick up the standard
318 # Mailman.Defaults.* variables.
319-from canonical.launchpad.mailman.monkeypatches.defaults import *
320+from lp.services.mailman.monkeypatches.defaults import *
321
322 # Our dynamic overrides of all the static defaults.
323 SMTPHOST = '%(smtp_host)s'
324
325=== renamed file 'lib/canonical/launchpad/mailman/runmailman.py' => 'lib/lp/services/mailman/runmailman.py'
326--- lib/canonical/launchpad/mailman/runmailman.py 2010-08-20 20:31:18 +0000
327+++ lib/lp/services/mailman/runmailman.py 2010-09-18 03:14:43 +0000
328@@ -17,8 +17,8 @@
329 import sys
330
331 import canonical
332-from canonical.launchpad.mailman.config import configure_prefix
333-from canonical.launchpad.mailman.monkeypatches import monkey_patch
334+from lp.services.mailman.config import configure_prefix
335+from lp.services.mailman.monkeypatches import monkey_patch
336
337
338 def mailmanctl(command, quiet=False, config=None, *additional_arguments):
339@@ -36,7 +36,7 @@
340 if config is None:
341 config = canonical.config.config
342 mailman_path = configure_prefix(config.mailman.build_prefix)
343- mailman_bin = os.path.join(mailman_path, 'bin')
344+ mailman_bin = os.path.join(mailman_path, 'bin')
345 args = ['./mailmanctl']
346 args.extend(additional_arguments)
347 args.append(command)
348@@ -117,7 +117,7 @@
349 # We need the Mailman bin directory so we can run some of Mailman's
350 # command line scripts.
351 mailman_path = configure_prefix(config.mailman.build_prefix)
352- mailman_bin = os.path.join(mailman_path, 'bin')
353+ mailman_bin = os.path.join(mailman_path, 'bin')
354
355 # Monkey-patch the installed Mailman 2.1 tree.
356 monkey_patch(mailman_path, config)
357
358=== modified file 'lib/lp/services/mailman/testing/layers.py'
359--- lib/lp/services/mailman/testing/layers.py 2010-08-20 20:31:18 +0000
360+++ lib/lp/services/mailman/testing/layers.py 2010-09-18 03:14:43 +0000
361@@ -12,7 +12,7 @@
362 import atexit
363 import os
364
365-from canonical.launchpad.mailman.runmailman import (
366+from lp.services.mailman.runmailman import (
367 start_mailman,
368 stop_mailman,
369 )
370
371=== modified file 'lib/lp/services/mailman/testing/withlist_1.py'
372--- lib/lp/services/mailman/testing/withlist_1.py 2010-08-20 20:31:18 +0000
373+++ lib/lp/services/mailman/testing/withlist_1.py 2010-09-18 03:14:43 +0000
374@@ -9,7 +9,7 @@
375 # This script must be called like so:
376 #
377 # bin/withlist -r \
378-# canonical.launchpad.mailman.tests.withlist_1.test_site_list mailman
379+# lp.services.mailman.tests.withlist_1.test_site_list mailman
380 #
381 # where the final argument is the name of the site list, which must exist.
382
383
384=== modified file 'lib/lp/services/mailman/testing/withlist_2.py'
385--- lib/lp/services/mailman/testing/withlist_2.py 2010-08-20 20:31:18 +0000
386+++ lib/lp/services/mailman/testing/withlist_2.py 2010-09-18 03:14:43 +0000
387@@ -8,14 +8,14 @@
388 #
389 # This script must be called like so:
390 #
391-# bin/withlist -r canonical.launchpad.mailman.tests.withlist_2.can_import
392+# bin/withlist -r lp.services.mailman.tests.withlist_2.can_import
393
394 import sys
395
396
397 def can_import(mlist):
398 try:
399- import canonical.launchpad.mailman
400+ import lp.services.mailman
401 except ImportError:
402 sys.exit(1)
403 else:
404
405=== modified file 'scripts/mlist-sync.py'
406--- scripts/mlist-sync.py 2010-04-27 19:48:39 +0000
407+++ scripts/mlist-sync.py 2010-09-18 03:14:43 +0000
408@@ -39,7 +39,7 @@
409 from canonical.config import config
410 from canonical.launchpad.interfaces import (
411 IEmailAddressSet, IMailingListSet, IPersonSet)
412-from canonical.launchpad.mailman.config import configure_prefix
413+from lp.services.mailman.config import configure_prefix
414 from lp.services.scripts.base import LaunchpadCronScript
415
416
417
418=== modified file 'utilities/launchpad-database-setup'
419--- utilities/launchpad-database-setup 2010-09-17 11:59:56 +0000
420+++ utilities/launchpad-database-setup 2010-09-18 03:14:43 +0000
421@@ -41,7 +41,12 @@
422 echo "ensure postgres is running on port 5432."
423 fi;
424
425-sudo /etc/init.d/postgresql stop $pgversion
426+if [ -e /etc/init.d/postgresql-$pgversion ]; then
427+ sudo /etc/init.d/postgresql-$pgversion stop
428+else
429+ # This is Maverick.
430+ sudo /etc/init.d/postgresql stop $pgversion
431+fi
432
433 echo Purging postgresql data...
434 sudo pg_dropcluster $pgversion main --stop-server
435@@ -99,7 +104,12 @@
436 EOF
437 fi
438
439-sudo /etc/init.d/postgresql start $pgversion
440+if [ -e /etc/init.d/postgresql-$pgversion ]; then
441+ sudo /etc/init.d/postgresql-$pgversion start
442+else
443+ # This is Maverick.
444+ sudo /etc/init.d/postgresql start $pgversion
445+fi
446
447 echo Waiting 10 seconds for postgresql to come up...
448 sleep 10