How about something like this code?

"""
Clear (erase) bounce statistics (scores) for all members (intended to be
used with the optional domain parameter only)
Modified from original reset_bounce.py by Mark Sapiro.

Save as bin/clear_bounce_info.py

Run via

   bin/withlist -r clear_bounce_info <listname> [options]
   bin/withlist -r clear_bounce_info <listname> --domain=example.com--verbose

or

   bin/withlist -a -r clear_bounce_info -- [options]

to do all lists.


Options:
    -d domain
    --domain=domain
        Only reset those users with addresses in domain.

    -v
    --verbose
        Print line for each member changed and a summary with total number
of users reset.
"""

import sys
import getopt

from Mailman import MemberAdaptor

def usage(code, msg=''):
    if code:
        fd = sys.stderr
    else:
        fd = sys.stdout
    print >> fd, __doc__
    if msg:
        print >> fd, msg
    sys.exit(code)

def clear_bounce_info(mlist, *args):

    try:
        opts, args = getopt.getopt(args, 'd:v', ['domain=', 'verbose'])
    except getopt.error, msg:
        usage(1, msg)

    verbose = 0
    domain = None
    for opt, arg in opts:
        if opt in ('-d', '--domain'):
            domain = arg.lower()
        elif opt in ('-v', '--verbose'):
            verbose = 1

    if not mlist.Locked():
        mlist.Lock()
    count = 0
    for member in mlist.getMembers():
        if domain and not member.endswith(domain):
            continue
        del mlist.bounce_info[member]
        count += 1
        if verbose:
            print 'list: %s - bounce info deleted for %s' %
(mlist.internal_name(), member)
    mlist.Save()
    mlist.Unlock()
    if verbose:
        print 'List %s: Reset %d bouncing members.' % (mlist.real_name,
count)


On Thu, Jun 7, 2012 at 11:49 AM, Barry S, Finkel <bsfin...@att.net> wrote:

> On 6/7/2012 10:23 AM, Terry Earley wrote:
>
>> We need to clear/reset bounce stats for Yahoo members on our list. we
>> modified Mark Sapiro's script at:
>> http://www.msapiro.net/**scripts/reset_bounce.py<http://www.msapiro.net/scripts/reset_bounce.py>
>> to modify only Yahoo email addresses, but it cleared only 2 that had been
>> bouncing. That squares with the comment at top:
>>
>>  """Enable delivery for all bouncing members.
>>>
>>>  is there a way to make it clear bounce stats for all (in this case
>> Yahoo)
>> to avoid these members from going over threshold? If not, we could run the
>> script after we get the admin notice that they are set to nomail for
>> bounces.
>>
>>  If I understand what you want, I believe you change:
>
>        if mlist.getDeliveryStatus(**member) == MemberAdaptor.BYBOUNCE:
>            mlist.setDeliveryStatus(**member, MemberAdaptor.ENABLED)
>            count += 1
> by removing the "if" line and un-indenting the next two lines.  This will
> set all addresses in the domain to ENABLED.  But, I believe, this will no
> do
> exactly what you want, because you are not resetting the bounce score.
> If a yahoo.com subscriber has a bounce score of 4, then setting
>
>     MemberAdaptor,ENABLED
>
> will be resetting the value to what it already is, and the next bounce
> will (if the bounce score trigger is the default 5.0) will set BYBOUNCE.
> I have not looked at the code to see if setting ENABLED also resets
> the bounce score back to 0.
> --Barry Finkel
>
>
------------------------------------------------------
Mailman-Users mailing list Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://wiki.list.org/x/AgA3
Security Policy: http://wiki.list.org/x/QIA9
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

Reply via email to