3
# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
3
# Copyright (C) 1998-2003 by the Free Software Foundation, Inc.
5
5
# This program is free software; you can redistribute it and/or
6
6
# modify it under the terms of the GNU General Public License
7
7
# as published by the Free Software Foundation; either version 2
8
8
# of the License, or (at your option) any later version.
10
10
# This program is distributed in the hope that it will be useful,
11
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
# GNU General Public License for more details.
15
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
19
"""Remove the components of a mailing list with impunity - beware!
64
def remove_it(listname, dir, msg):
65
if os.path.islink(dir):
66
print _('Removing %(msg)s')
68
elif os.path.isdir(dir):
69
print _('Removing %(msg)s')
70
def remove_it(listname, filename, msg):
71
if os.path.islink(filename):
72
print _('Removing %(msg)s')
74
elif os.path.isdir(filename):
75
print _('Removing %(msg)s')
76
shutil.rmtree(filename)
77
elif os.path.isfile(filename):
72
print _('%(listname)s %(msg)s not found as %(dir)s')
80
print _('%(listname)s %(msg)s not found as %(filename)s')
85
93
listname = args[0].lower().strip()
95
removeArchives = False
88
96
for opt, arg in opts:
89
97
if opt in ('-a', '--archives'):
91
99
elif opt in ('-h', '--help'):
94
102
if not Utils.list_exists(listname):
95
if not removeArchives:
96
usage(1, _('No such list (or list already deleted): %(listname)s'))
103
if not removeArchives:
104
usage(1, _('No such list (or list already deleted): %(listname)s'))
99
107
'No such list: %(listname)s. Removing its residual archives.')
101
109
if not removeArchives:
106
114
if Utils.list_exists(listname):
107
mlist = MailList.MailList(listname, lock=0)
109
# Do the MTA-specific list deletion tasks
111
modname = 'Mailman.MTA.' + mm_cfg.MTA
113
sys.modules[modname].remove(mlist)
116
(os.path.join('lists', listname), _('list info')),
115
mlist = MailList.MailList(listname, lock=0)
117
# Do the MTA-specific list deletion tasks
119
modname = 'Mailman.MTA.' + mm_cfg.MTA
121
sys.modules[modname].remove(mlist)
124
(os.path.join('lists', listname), _('list info')),
127
# Remove any stale locks associated with the list
128
for filename in os.listdir(mm_cfg.LOCK_DIR):
129
fn_listname = filename.split('.')[0]
130
if fn_listname == listname:
131
REMOVABLES.append((os.path.join(mm_cfg.LOCK_DIR, filename),
132
_('stale lock file')))
119
134
if removeArchives:
120
135
REMOVABLES.extend([
121
(os.path.join('archives', 'private', listname),
122
_('private archives')),
123
(os.path.join('archives', 'private', listname + '.mbox'),
124
_('private archives')),
125
(os.path.join('archives', 'public', listname),
136
(os.path.join('archives', 'private', listname),
137
_('private archives')),
138
(os.path.join('archives', 'private', listname + '.mbox'),
139
_('private archives')),
140
(os.path.join('archives', 'public', listname),
126
141
_('public archives')),
127
(os.path.join('archives', 'public', listname + '.mbox'),
142
(os.path.join('archives', 'public', listname + '.mbox'),
128
143
_('public archives')),