Пример #1
0
def main():
    parser, opts, args = parseargs()
    initialize(opts.config)

    list_manager = getUtility(IListManager)
    listnames = set(args or list_manager.names)
    bylist = {}

    for listname in listnames:
        mlist = list_manager.get(listname)
        addrs = [addr.address for addr in mlist.owners.addresses]
        if opts.moderators:
            addrs.extend([addr.address for addr in mlist.moderators.addresses])
        bylist[listname] = addrs

    if opts.with_listnames:
        for listname in listnames:
            unique = set()
            for addr in bylist[listname]:
                unique.add(addr)
            keys = list(unique)
            keys.sort()
            print listname
            for k in keys:
                print '\t', k
    else:
        unique = set()
        for listname in listnames:
            for addr in bylist[listname]:
                unique.add(addr)
        for k in sorted(unique):
            print k
Пример #2
0
def main():
    parser, opts, args = parseargs()
    initialize(opts.config)

    close = False
    if opts.outputfile in (None, '-'):
        writer = codecs.getwriter('utf-8')
        fp = writer(sys.stdout)
    else:
        fp = codecs.open(opts.outputfile, 'w', 'utf-8')
        close = True

    try:
        dumper = XMLDumper(fp)
        if opts.listnames:
            listnames = []
            for listname in opts.listnames:
                if '@' not in listname:
                    listname = '%s@%s' % (listname, config.DEFAULT_EMAIL_HOST)
                listnames.append(listname)
        else:
            listnames = config.list_manager.names
        dumper.dump(listnames)
        dumper.close()
    finally:
        if close:
            fp.close()
Пример #3
0
def main():
    parser, opts, args = parseargs()
    initialize(opts.config)

    list_manager = getUtility(IListManager)
    listnames = set(args or list_manager.names)
    bylist = {}

    for listname in listnames:
        mlist = list_manager.get(listname)
        addrs = [addr.address for addr in mlist.owners.addresses]
        if opts.moderators:
            addrs.extend([addr.address for addr in mlist.moderators.addresses])
        bylist[listname] = addrs

    if opts.with_listnames:
        for listname in listnames:
            unique = set()
            for addr in bylist[listname]:
                unique.add(addr)
            keys = list(unique)
            keys.sort()
            print listname
            for k in keys:
                print '\t', k
    else:
        unique = set()
        for listname in listnames:
            for addr in bylist[listname]:
                unique.add(addr)
        for k in sorted(unique):
            print k
Пример #4
0
def main():
    parser, opts, args = parseargs()
    initialize(opts.config)

    close = False
    if opts.outputfile in (None, '-'):
        writer = codecs.getwriter('utf-8')
        fp = writer(sys.stdout)
    else:
        fp = codecs.open(opts.outputfile, 'w', 'utf-8')
        close = True

    try:
        dumper = XMLDumper(fp)
        if opts.listnames:
            listnames = []
            for listname in opts.listnames:
                if '@' not in listname:
                    listname = '%s@%s' % (listname, config.DEFAULT_EMAIL_HOST)
                listnames.append(listname)
        else:
            listnames = config.list_manager.names
        dumper.dump(listnames)
        dumper.close()
    finally:
        if close:
            fp.close()
Пример #5
0
def main():
    opts, args, parser = parseargs()
    initialize(opts.config)

    for name in config.list_manager.names:
        # The list must be locked in order to open the requests database
        mlist = MailList.MailList(name)
        try:
            count = IListRequests(mlist).count
            # While we're at it, let's evict yesterday's autoresponse data
            midnight_today = midnight()
            evictions = []
            for sender in mlist.hold_and_cmd_autoresponses.keys():
                date, respcount = mlist.hold_and_cmd_autoresponses[sender]
                if midnight(date) < midnight_today:
                    evictions.append(sender)
            if evictions:
                for sender in evictions:
                    del mlist.hold_and_cmd_autoresponses[sender]
                # This is the only place we've changed the list's database
                mlist.Save()
            if count:
                # Set the default language the the list's preferred language.
                _.default = mlist.preferred_language
                realname = mlist.real_name
                discarded = auto_discard(mlist)
                if discarded:
                    count = count - discarded
                    text = _('Notice: $discarded old request(s) '
                             'automatically expired.\n\n')
                else:
                    text = ''
                if count:
                    text += Utils.maketext(
                        'checkdbs.txt',
                        {'count'    : count,
                         'mail_host': mlist.mail_host,
                         'adminDB'  : mlist.GetScriptURL('admindb',
                                                         absolute=1),
                         'real_name': realname,
                         }, mlist=mlist)
                    text += '\n' + pending_requests(mlist)
                    subject = _('$count $realname moderator '
                                'request(s) waiting')
                else:
                    subject = _('$realname moderator request check result')
                msg = UserNotification(mlist.GetOwnerEmail(),
                                       mlist.GetBouncesEmail(),
                                       subject, text,
                                       mlist.preferred_language)
                msg.send(mlist, **{'tomoderators': True})
        finally:
            mlist.Unlock()
Пример #6
0
def main():
    opts, args, parser = parseargs()
    initialize(opts.config)

    for name in config.list_manager.names:
        # The list must be locked in order to open the requests database
        mlist = MailList.MailList(name)
        try:
            count = IListRequests(mlist).count
            # While we're at it, let's evict yesterday's autoresponse data
            midnight_today = midnight()
            evictions = []
            for sender in mlist.hold_and_cmd_autoresponses.keys():
                date, respcount = mlist.hold_and_cmd_autoresponses[sender]
                if midnight(date) < midnight_today:
                    evictions.append(sender)
            if evictions:
                for sender in evictions:
                    del mlist.hold_and_cmd_autoresponses[sender]
                # This is the only place we've changed the list's database
                mlist.Save()
            if count:
                # Set the default language the the list's preferred language.
                _.default = mlist.preferred_language
                realname = mlist.real_name
                discarded = auto_discard(mlist)
                if discarded:
                    count = count - discarded
                    text = _('Notice: $discarded old request(s) '
                             'automatically expired.\n\n')
                else:
                    text = ''
                if count:
                    text += Utils.maketext(
                        'checkdbs.txt', {
                            'count': count,
                            'mail_host': mlist.mail_host,
                            'adminDB': mlist.GetScriptURL('admindb',
                                                          absolute=1),
                            'real_name': realname,
                        },
                        mlist=mlist)
                    text += '\n' + pending_requests(mlist)
                    subject = _('$count $realname moderator '
                                'request(s) waiting')
                else:
                    subject = _('$realname moderator request check result')
                msg = UserNotification(mlist.GetOwnerEmail(),
                                       mlist.GetBouncesEmail(), subject, text,
                                       mlist.preferred_language)
                msg.send(mlist, **{'tomoderators': True})
        finally:
            mlist.Unlock()
Пример #7
0
def main():
    parser, opts, args = parseargs()
    initialize(opts.config)
    listname = args[0]

    # Sanity check
    if opts.inputfile and opts.outputfile:
        parser.error(_("Only one of -i or -o is allowed"))
    if not opts.inputfile and not opts.outputfile:
        parser.error(_("One of -i or -o is required"))

    if opts.outputfile:
        do_output(listname, opts.outputfile, parser)
    else:
        do_input(listname, opts.inputfile, opts.checkonly, opts.verbose, parser)
Пример #8
0
def main():
    parser, opts, args = parseargs()
    initialize(opts.config)
    listname = args[0]

    # Sanity check
    if opts.inputfile and opts.outputfile:
        parser.error(_('Only one of -i or -o is allowed'))
    if not opts.inputfile and not opts.outputfile:
        parser.error(_('One of -i or -o is required'))

    if opts.outputfile:
        do_output(listname, opts.outputfile, parser)
    else:
        do_input(listname, opts.inputfile, opts.checkonly, opts.verbose,
                 parser)
Пример #9
0
def main():
    opts, args, parser = parseargs()
    initialize(opts.config)

    for listname in set(opts.listnames or config.list_manager.names):
        mlist = MailList.MailList(listname, lock=False)
        if mlist.digest_send_periodic:
            mlist.Lock()
            try:
                try:
                    mlist.send_digest_now()
                    mlist.Save()
                # We are unable to predict what exception may occur in digest
                # processing and we don't want to lose the other digests, so
                # we catch everything.
                except Exception, errmsg:
                    print >> sys.stderr, \
                      'List: %s: problem processing %s:\n%s' % \
                        (listname,
                         os.path.join(mlist.data_path, 'digest.mbox'),
                         errmsg)
            finally:
                mlist.Unlock()
Пример #10
0
def main():
    opts, args, parser = parseargs()
    initialize(opts.config)

    for listname in set(opts.listnames or config.list_manager.names):
        mlist = MailList.MailList(listname, lock=False)
        if mlist.digest_send_periodic:
            mlist.Lock()
            try:
                try:
                    mlist.send_digest_now()
                    mlist.Save()
                # We are unable to predict what exception may occur in digest
                # processing and we don't want to lose the other digests, so
                # we catch everything.
                except Exception as errmsg:
                    print >> sys.stderr, \
                      'List: %s: problem processing %s:\n%s' % \
                        (listname,
                         os.path.join(mlist.data_path, 'digest.mbox'),
                         errmsg)
            finally:
                mlist.Unlock()