def test_deactivate(self):
     # Lists are deactivted in mailman after they are deactivate in Lp.
     team, mailing_list = self.makeTeamList('team-1', 'owner-1')
     mailing_list.deactivate()
     self.runner._oneloop()
     self.assertContentEqual([mm_cfg.MAILMAN_SITE_LIST], list_names())
     backup_file = os.path.join(mm_cfg.VAR_PREFIX, 'backups', 'team-1.tgz')
     self.assertTrue(os.path.exists(backup_file))
     tarball = tarfile.open(backup_file, 'r:gz')
     content = ['team-1', 'team-1/config.pck']
     self.assertContentEqual(content, tarball.getnames())
     self.assertEqual(MailingListStatus.INACTIVE, mailing_list.status)
Exemple #2
0
 def test_deactivate(self):
     # Lists are deactivted in mailman after they are deactivate in Lp.
     team, mailing_list = self.makeTeamList('team-1', 'owner-1')
     mailing_list.deactivate()
     self.runner._oneloop()
     self.assertContentEqual([mm_cfg.MAILMAN_SITE_LIST], list_names())
     backup_file = os.path.join(mm_cfg.VAR_PREFIX, 'backups', 'team-1.tgz')
     self.assertTrue(os.path.exists(backup_file))
     tarball = tarfile.open(backup_file, 'r:gz')
     content = ['team-1', 'team-1/config.pck']
     self.assertContentEqual(content, tarball.getnames())
     self.assertEqual(MailingListStatus.INACTIVE, mailing_list.status)
Exemple #3
0
 def test_create(self):
     # Lists are created in mailman after they are created in Lp.
     team = self.factory.makeTeam(name='team-1')
     # The factory cannot be used because it forces the list into a
     # usable state.
     mailing_list = getUtility(IMailingListSet).new(team, team.teamowner)
     self.runner._oneloop()
     self.assertContentEqual([mm_cfg.MAILMAN_SITE_LIST, 'team-1'],
                             list_names())
     mm_list = MailList.MailList('team-1')
     self.addCleanup(self.cleanMailmanList, mm_list)
     self.assertEqual('*****@*****.**',
                      mm_list.getListAddress())
     self.assertEqual(MailingListStatus.ACTIVE, mailing_list.status)
 def test_create(self):
     # Lists are created in mailman after they are created in Lp.
     team = self.factory.makeTeam(name='team-1')
     # The factory cannot be used because it forces the list into a
     # usable state.
     mailing_list = getUtility(IMailingListSet).new(team, team.teamowner)
     self.runner._oneloop()
     self.assertContentEqual(
         [mm_cfg.MAILMAN_SITE_LIST, 'team-1'], list_names())
     mm_list = MailList.MailList('team-1')
     self.addCleanup(self.cleanMailmanList, mm_list)
     self.assertEqual(
         '*****@*****.**', mm_list.getListAddress())
     self.assertEqual(MailingListStatus.ACTIVE, mailing_list.status)
Exemple #5
0
 def test_nonexistent_to_active_recovery(self):
     # Mailman will build the list if Lp thinks it is exists in the
     # CONSTRUCTING state
     team = self.factory.makeTeam(name='team-1')
     mailing_list = getUtility(IMailingListSet).new(team, team.teamowner)
     removeSecurityProxy(mailing_list).status = (
         MailingListStatus.CONSTRUCTING)
     self.runner._oneloop()
     self.assertContentEqual([mm_cfg.MAILMAN_SITE_LIST, 'team-1'],
                             list_names())
     mm_list = MailList.MailList('team-1')
     self.addCleanup(self.cleanMailmanList, mm_list)
     self.assertEqual('*****@*****.**',
                      mm_list.getListAddress())
     self.assertEqual(MailingListStatus.ACTIVE, mailing_list.status)
 def test_nonexistent_to_active_recovery(self):
     # Mailman will build the list if Lp thinks it is exists in the
     # CONSTRUCTING state
     team = self.factory.makeTeam(name='team-1')
     mailing_list = getUtility(IMailingListSet).new(team, team.teamowner)
     removeSecurityProxy(mailing_list).status = (
         MailingListStatus.CONSTRUCTING)
     self.runner._oneloop()
     self.assertContentEqual(
         [mm_cfg.MAILMAN_SITE_LIST, 'team-1'], list_names())
     mm_list = MailList.MailList('team-1')
     self.addCleanup(self.cleanMailmanList, mm_list)
     self.assertEqual(
         '*****@*****.**', mm_list.getListAddress())
     self.assertEqual(MailingListStatus.ACTIVE, mailing_list.status)
 def getListInfo(self):
     """Return a list of 4-tuples of Mailman mailing list info."""
     list_info = []
     for list_name in sorted(list_names()):
         if list_name == mm_cfg.MAILMAN_SITE_LIST:
             continue
         mailing_list = MailList(list_name, lock=False)
         list_address = mailing_list.getListAddress()
         if self.naked_email_address_set.getByEmail(list_address) is None:
             email = '%s not found' % list_address
         else:
             email = list_address
         list_info.append(
             (mailing_list.internal_name(), mailing_list.host_name,
              mailing_list.web_page_url, email))
     return list_info
 def getListInfo(self):
     """Return a list of 4-tuples of Mailman mailing list info."""
     list_info = []
     for list_name in sorted(list_names()):
         if list_name == mm_cfg.MAILMAN_SITE_LIST:
             continue
         mailing_list = MailList(list_name, lock=False)
         list_address = mailing_list.getListAddress()
         if self.naked_email_address_set.getByEmail(list_address) is None:
             email = '%s not found' % list_address
         else:
             email = list_address
         list_info.append(
             (mailing_list.internal_name(), mailing_list.host_name,
              mailing_list.web_page_url, email))
     return list_info
Exemple #9
0
def main():
	for x in list_names():
		ml = MailList(x, True)
		try:
			changed = False
			for o in ml.owner:
				if not o in ALLOWED_OWNERS:
					print 'Removing %s from %s' % (o, x)
					ml.owner.remove(o)
					changed = True
			if not ml.owner:
				ml.owner.append(ALLOWED_OWNERS[0])
				changed = True
			if changed:
				ml.Save()
		finally:
			ml.Unlock()
Exemple #10
0
def main():
    for x in list_names():
        ml = MailList(x, True)
        try:
            changed = False
            for o in ml.owner:
                if not o in ALLOWED_OWNERS:
                    print 'Removing %s from %s' % (o, x)
                    ml.owner.remove(o)
                    changed = True
            if not ml.owner:
                ml.owner.append(ALLOWED_OWNERS[0])
                changed = True
            if changed:
                ml.Save()
        finally:
            ml.Unlock()
def main():
    for x in list_names():
        ml = MailList(x, True)
        try:
            changed = False
            if ml.host_name != settings.LISTS_MAILDOMAIN:
                print 'Updating host_name of %s' % x
                ml.host_name = settings.LISTS_MAILDOMAIN
                changed = True
            if ml.from_is_list != 1:
                print 'Updating from_is_list of %s' % x
                ml.from_is_list = 1
                changed = True
            if changed:
                print 'Saving %s' % x
                ml.Save()
        finally:
            ml.Unlock()
def main():
    for x in list_names():
        ml = MailList(x, True)
        try:
            changed = False
            if ml.host_name != settings.LISTS_MAILDOMAIN:
                print 'Updating host_name of %s' % x
                ml.host_name = settings.LISTS_MAILDOMAIN
                changed = True
            if ml.from_is_list != 1:
                print 'Updating from_is_list of %s' % x
                ml.from_is_list = 1
                changed = True
            if changed:
                print 'Saving %s' % x
                ml.Save()
        finally:
            ml.Unlock()
Exemple #13
0
def main():
    url = 'https://%s/mailman/' % settings.MAILDOMAIN
    for x in list_names():
        ml = MailList(x, True)
        try:
            changed = False
            if ml.host_name != settings.LISTS_MAILDOMAIN:
                print 'Updating host_name of %s (was %s)' % (x, ml.host_name)
                ml.host_name = settings.LISTS_MAILDOMAIN
                changed = True
            if ml.from_is_list != 1:
                print 'Updating from_is_list of %s' % x
                ml.from_is_list = 1
                changed = True
            if ml.web_page_url != url:
                print 'Updating url_host of %s (was %s)' % (x, ml.web_page_url)
                ml.web_page_url = url
                changed = True
            # if changed:
            #    print 'Saving %s' % x
            #    ml.Save()
        finally:
            ml.Unlock()
Exemple #14
0
def main():
    url = 'https://%s/mailman/' % settings.MAILDOMAIN
    for x in list_names():
        ml = MailList(x, True)
        try:
            changed = False
            if ml.host_name != settings.LISTS_MAILDOMAIN:
                print('Updating host_name of %s (was %s)' % (x, ml.host_name))
                ml.host_name = settings.LISTS_MAILDOMAIN
                changed = True
            if ml.from_is_list != 1:
                print('Updating from_is_list of %s' % x)
                ml.from_is_list = 1
                changed = True
            if ml.web_page_url != url:
                print('Updating url_host of %s (was %s)' %
                      (x, ml.web_page_url))
                ml.web_page_url = url
                changed = True
            if changed:
                print('Saving %s' % x)
            #    ml.Save()
        finally:
            ml.Unlock()
#!/usr/bin/python2

import imp
import json
import sys

paths = imp.load_source('paths', '/usr/lib/mailman/bin/paths.py')

from Mailman.MailList import MailList
from Mailman.Utils import list_names

json.dump(
    {
        'ansible_facts': {
            'mailman': {
                'lists': [
                    MailList(name, lock=0).internal_name()
                    for name in list_names()
                ],
            },
        },
    },
    sys.stdout,
    indent=2)