예제 #1
0
파일: mailman.py 프로젝트: Jille/kninfra
from subprocess import call
import logging
import os

from kn import settings

from kn.utils.mailman import import_mailman
import_mailman()
from Mailman import Utils, MailList, UserDesc, Errors, mm_cfg

def apply_mailman_changes(daan, changes):
    mlo = {}
    def ensure_opened(l):
        if l in mlo:
            return True
        try:
            mlo[l] = MailList.MailList(l)
            return True
        except Errors.MMUnknownListError:
            logging.warn("mailman: could not open %s" % l)
        return False
    for name, humanName in changes['create']:
        newlist = os.path.join(settings.MAILMAN_PATH, 'bin/newlist')
        ret = call([newlist, '-q', name, settings.MAILMAN_DEFAULT_OWNER,
                    settings.MAILMAN_DEFAULT_PASSWORD])
        if ret != 0:
            logging.error("bin/newlist failed")
            continue
        # Our custom settings
        # from: http://karpenoktem.com/wiki/WebCie:Mailinglist
        ensure_opened(name)
예제 #2
0
from subprocess import call
import logging
import os

from kn import settings

from kn.utils.mailman import import_mailman

import_mailman()
from Mailman import Utils, MailList, UserDesc, Errors, mm_cfg


def apply_mailman_changes(daan, changes):
    mlo = {}

    def ensure_opened(l):
        if l in mlo:
            return True
        try:
            mlo[l] = MailList.MailList(l)
            return True
        except Errors.MMUnknownListError:
            logging.warn("mailman: could not open %s" % l)
        return False

    for name, humanName in changes['create']:
        newlist = os.path.join(settings.MAILMAN_PATH, 'bin/newlist')
        ret = call([
            newlist, '-q', name, settings.MAILMAN_DEFAULT_OWNER,
            settings.MAILMAN_DEFAULT_PASSWORD
        ])