# Copyright (C) 2010 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 # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. """Find a bouncing member that's not a member and remove bounce_info. Also remove stale bounce info. Save as bin/fix_bad_bounce_info.py Run via bin/withlist -a -r fix_bad_bounce_info """ import time from Mailman import Utils from Mailman.MemberAdaptor import BYBOUNCE def fix_bad_bounce_info(mlist): if not mlist.Locked(): mlist.Lock() now = Utils.midnight(time.localtime()[:3]) for member in mlist.getBouncingMembers(): if not mlist.isMember(member): del mlist.bounce_info[member] print 'list: %s - non-member: %s - bounce_info deleted'\ % (mlist.internal_name(), member) continue if mlist.getDeliveryStatus(member) == BYBOUNCE: # This member is being handled by cron/disabled. continue info = mlist.bounce_info[member] # See if this member's bounce information is stale. lastbounce = Utils.midnight(info.date) if lastbounce + mlist.bounce_info_stale_after < now: # Information is stale, so discard it. del mlist.bounce_info[member] print 'list: %s - member: %s - stale bounce_info deleted'\ % (mlist.internal_name(), member) mlist.Save() mlist.Unlock()