def main(): parser, opts, args = parseargs() config.load(opts.config) listnames = opts.listnames or config.list_manager.names includes = set(listname.lower() for listname in listnames) excludes = set(listname.lower() for listname in opts.excludes) listnames = includes - excludes if not listnames: print _('No lists to search') return cres = [] for r in args: cres.append(re.compile(r, re.IGNORECASE)) # dictionary of {address, (listname, ownerp)} matches = {} for listname in listnames: try: mlist = MailList.MailList(listname, lock=False) except errors.MMListError: print _('No such list: $listname') continue if opts.owners: owners = mlist.owner else: owners = [] for cre in cres: for member in mlist.getMembers(): if cre.search(member): addr = mlist.getMemberCPAddress(member) entries = matches.get(addr, {}) aswhat = entries.get(listname, 0) aswhat |= AS_MEMBER entries[listname] = aswhat matches[addr] = entries for owner in owners: if cre.search(owner): entries = matches.get(owner, {}) aswhat = entries.get(listname, 0) aswhat |= AS_OWNER entries[listname] = aswhat matches[owner] = entries addrs = matches.keys() addrs.sort() for k in addrs: hits = matches[k] lists = hits.keys() print k, _('found in:') for name in lists: aswhat = hits[name] if aswhat & AS_MEMBER: print ' ', name if aswhat & AS_OWNER: print ' ', name, _('(as owner)')
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')
def main(): opts, args, parser = parseargs() config.load(opts.config) listnames = set(args or config.list_manager.names) if not listnames: print _("Nothing to do.") sys.exit(0) for listname in listnames: try: # Be sure the list is locked mlist = MailList.MailList(listname) except errors.MMListError: parser.print_help() print >> sys.stderr, _("No such list: $listname") sys.exit(1) try: mlist.bump_digest_volume() finally: mlist.Save() mlist.Unlock()
def main(): opts, args, parser = parseargs() config.load(opts.config) listnames = set(args or config.list_manager.names) if not listnames: print(_('Nothing to do.')) sys.exit(0) for listname in listnames: try: # Be sure the list is locked mlist = MailList.MailList(listname) except errors.MMListError: parser.print_help() print(_('No such list: $listname'), file=sys.stderr) sys.exit(1) try: mlist.bump_digest_volume() finally: mlist.Save() mlist.Unlock()
def main(): parser, opts, args = parseargs() patterns = [] if opts.ignorecase: flag = re.IGNORECASE else: flag = 0 for pattern in args: patterns.append(re.compile(pattern, flag)) pp = pprint.PrettyPrinter(indent=4) config.load(opts.config) names = config.__dict__.keys() names.sort() for name in names: if name in NEVER_SHOW: continue if not opts.verbose: if name.startswith('_') or re.search('[a-z]', name): continue if patterns: hit = False for pattern in patterns: if pattern.search(name): hit = True break if not hit: continue value = config.__dict__[name] if isinstance(value, str): if re.search('\n', value): print '%s = """%s"""' %(name, value) else: print "%s = '%s'" % (name, value) else: print '%s = ' % name, pp.pprint(value)
def main(): parser, opts, args = parseargs() patterns = [] if opts.ignorecase: flag = re.IGNORECASE else: flag = 0 for pattern in args: patterns.append(re.compile(pattern, flag)) pp = pprint.PrettyPrinter(indent=4) config.load(opts.config) names = config.__dict__.keys() names.sort() for name in names: if name in NEVER_SHOW: continue if not opts.verbose: if name.startswith('_') or re.search('[a-z]', name): continue if patterns: hit = False for pattern in patterns: if pattern.search(name): hit = True break if not hit: continue value = config.__dict__[name] if isinstance(value, str): if re.search('\n', value): print '%s = """%s"""' % (name, value) else: print "%s = '%s'" % (name, value) else: print '%s = ' % name, pp.pprint(value)
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()