summaryrefslogtreecommitdiff
path: root/bin/sync_members
diff options
context:
space:
mode:
authorbwarsaw2002-02-02 03:45:12 +0000
committerbwarsaw2002-02-02 03:45:12 +0000
commite33a6d0f2f696e0b7251c73a6b431e39834b27f4 (patch)
tree4075bbd17fb5bc2a5d09b91c21590245e1b274c6 /bin/sync_members
parent9d36b2459f93760b12939047db97d4e4babc4d2e (diff)
downloadmailman-e33a6d0f2f696e0b7251c73a6b431e39834b27f4.tar.gz
mailman-e33a6d0f2f696e0b7251c73a6b431e39834b27f4.tar.zst
mailman-e33a6d0f2f696e0b7251c73a6b431e39834b27f4.zip
main(): Several fixes:
- When Errors.EmailAddressError is raised, the translatable string in the print statement was illegal. - If an email address showed up twice in the sync file, a dry-run would have shown that address to be addable, even if it was already a member of the list. - If there were legacy illegal address in the user database (e.g. aperson@@dom.ain), then ApprovedDeleteMember() would fail on it with an MMNoSuchUserError, because parseaddr() in the former method would return some bogus address like "aperson@". In that case, use a lower level routine to delete the bogus record from the member database.
Diffstat (limited to 'bin/sync_members')
-rwxr-xr-xbin/sync_members20
1 files changed, 15 insertions, 5 deletions
diff --git a/bin/sync_members b/bin/sync_members
index 70eff1b32..fa7410ee1 100755
--- a/bin/sync_members
+++ b/bin/sync_members
@@ -1,6 +1,6 @@
#! @PYTHON@
#
-# Copyright (C) 1998,1999,2000,2001 by the Free Software Foundation, Inc.
+# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -189,7 +189,7 @@ def main():
try:
Utils.ValidateEmail(addr)
except Errors.EmailAddressError:
- print _('Invalid : %30(addr)s')
+ print _('Invalid : %(addr)30s')
invalid = 1
if invalid:
print _('You must fix the preceding invalid addresses first.')
@@ -206,6 +206,7 @@ def main():
# Get the list of addresses currently subscribed
addrs = {}
needsadding = {}
+ matches = {}
for addr in mlist.getMemberCPAddresses(mlist.getMembers()):
addrs[addr.lower()] = addr
@@ -215,7 +216,8 @@ def main():
laddr = addr.lower()
if addrs.has_key(laddr):
del addrs[laddr]
- else:
+ matches[laddr] = 1
+ elif not matches.has_key(laddr):
needsadding[laddr] = (name, addr)
if not needsadding and not addrs:
@@ -238,10 +240,18 @@ def main():
pass
for laddr, addr in addrs.items():
- name = mlist.getMemberName(addr)
+ name = mlist.getMemberName(laddr) or ''
# should be a member, otherwise our test above is broken
if not dryrun:
- mlist.DeleteMember(addr, admin_notif=notifyadmin)
+ try:
+ mlist.ApprovedDeleteMember(addr, admin_notif=notifyadmin,
+ userack=0)
+ except Errors.MMNoSuchUserError:
+ # This can happen if the address is illegal (i.e. can't be
+ # parsed by email.Utils.parseaddr()) but for legacy
+ # reasons is in the database. Use a lower level remove to
+ # get rid of this member's entry
+ mlist.removeMember(addr)
print _('Removed: <%(addr)30s> %(name)s')
mlist.Save()