blob: 0158c9b3763ff839d5ba8d6950ff8ac62e5c1fe1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
=========================
Command line list removal
=========================
A system administrator can remove mailing lists by the command line.
>>> create_list('test@example.com')
<mailing list "test@example.com" at ...>
>>> from mailman.interfaces.listmanager import IListManager
>>> from zope.component import getUtility
>>> list_manager = getUtility(IListManager)
>>> list_manager.get('test@example.com')
<mailing list "test@example.com" at ...>
>>> class FakeArgs:
... quiet = False
... archives = False
... listname = ['test@example.com']
>>> args = FakeArgs()
>>> from mailman.commands.cli_lists import Remove
>>> command = Remove()
>>> command.process(args)
Removed list: test@example.com
Not removing archives. Reinvoke with -a to remove them.
>>> print list_manager.get('test@example.com')
None
You can also remove lists quietly.
>>> create_list('test@example.com')
<mailing list "test@example.com" at ...>
>>> args.quiet = True
>>> command.process(args)
>>> print list_manager.get('test@example.com')
None
Removing archives
=================
By default 'mailman remove' does not remove a mailing list's archives.
>>> create_list('test@example.com')
<mailing list "test@example.com" at ...>
# Fake an mbox file for the mailing list.
>>> import os
>>> def make_mbox(fqdn_listname):
... mbox_dir = os.path.join(
... config.PUBLIC_ARCHIVE_FILE_DIR, fqdn_listname + '.mbox')
... os.makedirs(mbox_dir)
... mbox_file = os.path.join(mbox_dir, fqdn_listname + '.mbox')
... with open(mbox_file, 'w') as fp:
... print >> fp, 'A message'
... assert os.path.exists(mbox_file)
... return mbox_file
>>> mbox_file = make_mbox('test@example.com')
>>> args.quiet = False
>>> command.process(args)
Removed list: test@example.com
Not removing archives. Reinvoke with -a to remove them.
>>> os.path.exists(mbox_file)
True
Even if the mailing list has been deleted, you can still delete the archives
afterward.
>>> args.archives = True
>>> command.process(args)
No such list: test@example.com; removing residual archives.
>>> os.path.exists(mbox_file)
False
|