Exemple #1
0
def main():
    opts, args, parser = parseargs()
    config.load(opts.config)

    GATENEWS_LOCK_FILE = os.path.join(config.LOCK_DIR, 'gate_news.lock')
    LOCK_LIFETIME = config.hours(2)

    loginit.initialize(propagate=True)
    log = logging.getLogger('mailman.fromusenet')

    try:
        with Lock(GATENEWS_LOCK_FILE,
                  # It's okay to hijack this
                  lifetime=LOCK_LIFETIME) as lock:
            process_lists(lock)
        clearcache()
    except TimeOutError:
        log.error('Could not acquire gate_news lock')
Exemple #2
0
def main():
    opts, args, parser = parseargs()
    config.load(opts.config)

    loginit.initialize(propagate=True)
    elog = logging.getLogger('mailman.error')
    blog = logging.getLogger('mailman.bounce')

    listnames = set(opts.listnames or config.list_manager.names)
    who = tuple(opts.who)

    msg = _('[disabled by periodic sweep and cull, no message available]')
    today = time.mktime(time.localtime()[:3] + (0,) * 6)
    for listname in listnames:
        # List of members to notify
        notify = []
        mlist = MailList.MailList(listname)
        try:
            interval = mlist.bounce_you_are_disabled_warnings_interval
            # Find all the members who are currently bouncing and see if
            # they've reached the disable threshold but haven't yet been
            # disabled.  This is a sweep through the membership catching
            # situations where they've bounced a bunch, then the list admin
            # lowered the threshold, but we haven't (yet) seen more bounces
            # from the member.  Note: we won't worry about stale information
            # or anything else since the normal bounce processing code will
            # handle that.
            disables = []
            for member in mlist.getBouncingMembers():
                if mlist.getDeliveryStatus(member) <> MemberAdaptor.ENABLED:
                    continue
                info = mlist.getBounceInfo(member)
                if info.score >= mlist.bounce_score_threshold:
                    disables.append((member, info))
            if disables:
                for member, info in disables:
                    mlist.disableBouncingMember(member, info, msg)
            # Go through all the members who have delivery disabled, and find
            # those that are due to have another notification.  If they are
            # disabled for another reason than bouncing, and we're processing
            # them (because of the command line switch) then they won't have a
            # bounce info record.  We can piggyback on that for all disable
            # purposes.
            members = mlist.getDeliveryStatusMembers(who)
            for member in members:
                info = mlist.getBounceInfo(member)
                if not info:
                    # See if they are bounce disabled, or disabled for some
                    # other reason.
                    status = mlist.getDeliveryStatus(member)
                    if status == MemberAdaptor.BYBOUNCE:
                        elog.error(
                            '%s disabled BYBOUNCE lacks bounce info, list: %s',
                            member, mlist.internal_name())
                        continue
                    info = _BounceInfo(
                        member, 0, today,
                        mlist.bounce_you_are_disabled_warnings,
                        mlist.pend_new(Pending.RE_ENABLE,
                                       mlist.internal_name(),
                                       member))
                    mlist.setBounceInfo(member, info)
                lastnotice = time.mktime(info.lastnotice + (0,) * 6)
                if opts.force or today >= lastnotice + interval:
                    notify.append(member)
            # Now, send notifications to anyone who is due
            for member in notify:
                blog.info('Notifying disabled member %s for list: %s',
                          member, mlist.internal_name())
                try:
                    mlist.sendNextNotification(member)
                except NotAMemberError:
                    # There must have been some problem with the data we have
                    # on this member.  Most likely it's that they don't have a
                    # password assigned.  Log this and delete the member.
                    blog.info(
                        'Cannot send disable notice to non-member: %s',
                        member)
                    mlist.ApprovedDeleteMember(member, 'cron/disabled')
            mlist.Save()
        finally:
            mlist.Unlock()
Exemple #3
0
def main():
    opts, args, parser = parseargs()
    config.load(opts.config)

    loginit.initialize(propagate=True)
    elog = logging.getLogger('mailman.error')
    blog = logging.getLogger('mailman.bounce')

    listnames = set(opts.listnames or config.list_manager.names)
    who = tuple(opts.who)

    msg = _('[disabled by periodic sweep and cull, no message available]')
    today = time.mktime(time.localtime()[:3] + (0,) * 6)
    for listname in listnames:
        # List of members to notify
        notify = []
        mlist = MailList.MailList(listname)
        try:
            interval = mlist.bounce_you_are_disabled_warnings_interval
            # Find all the members who are currently bouncing and see if
            # they've reached the disable threshold but haven't yet been
            # disabled.  This is a sweep through the membership catching
            # situations where they've bounced a bunch, then the list admin
            # lowered the threshold, but we haven't (yet) seen more bounces
            # from the member.  Note: we won't worry about stale information
            # or anything else since the normal bounce processing code will
            # handle that.
            disables = []
            for member in mlist.getBouncingMembers():
                if mlist.getDeliveryStatus(member) <> MemberAdaptor.ENABLED:
                    continue
                info = mlist.getBounceInfo(member)
                if info.score >= mlist.bounce_score_threshold:
                    disables.append((member, info))
            if disables:
                for member, info in disables:
                    mlist.disableBouncingMember(member, info, msg)
            # Go through all the members who have delivery disabled, and find
            # those that are due to have another notification.  If they are
            # disabled for another reason than bouncing, and we're processing
            # them (because of the command line switch) then they won't have a
            # bounce info record.  We can piggyback on that for all disable
            # purposes.
            members = mlist.getDeliveryStatusMembers(who)
            for member in members:
                info = mlist.getBounceInfo(member)
                if not info:
                    # See if they are bounce disabled, or disabled for some
                    # other reason.
                    status = mlist.getDeliveryStatus(member)
                    if status == MemberAdaptor.BYBOUNCE:
                        elog.error(
                            '%s disabled BYBOUNCE lacks bounce info, list: %s',
                            member, mlist.internal_name())
                        continue
                    info = _BounceInfo(
                        member, 0, today,
                        mlist.bounce_you_are_disabled_warnings,
                        mlist.pend_new(Pending.RE_ENABLE,
                                       mlist.internal_name(),
                                       member))
                    mlist.setBounceInfo(member, info)
                lastnotice = time.mktime(info.lastnotice + (0,) * 6)
                if opts.force or today >= lastnotice + interval:
                    notify.append(member)
            # Now, send notifications to anyone who is due
            for member in notify:
                blog.info('Notifying disabled member %s for list: %s',
                          member, mlist.internal_name())
                try:
                    mlist.sendNextNotification(member)
                except NotAMemberError:
                    # There must have been some problem with the data we have
                    # on this member.  Most likely it's that they don't have a
                    # password assigned.  Log this and delete the member.
                    blog.info(
                        'Cannot send disable notice to non-member: %s',
                        member)
                    mlist.ApprovedDeleteMember(member, 'cron/disabled')
            mlist.Save()
        finally:
            mlist.Unlock()