From 4eb20d7ab4789ca6aeb8ad7cab31e2c040e5a8f3 Mon Sep 17 00:00:00 2001 From: glondu Date: Fri, 7 Apr 2006 18:27:08 +0200 Subject: [PATCH] On inscrit la ML com-ens de manire "propre". darcs-hash:20060407162708-68412-df53f8511e55b324e05614725fbb5b48ade44827.gz --- gestion/gen_confs/adherents.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/gestion/gen_confs/adherents.py b/gestion/gen_confs/adherents.py index e4c8f3eb..656ebbe0 100755 --- a/gestion/gen_confs/adherents.py +++ b/gestion/gen_confs/adherents.py @@ -4,12 +4,22 @@ # Copyright (C) Frédéric Pauget # Licence : GPLv2 -import smtplib, sys, commands, shutil, os +import smtplib, sys, commands, shutil, os, traceback sys.path.append('/usr/scripts/gestion') from affich_tools import cprint, anim, OK, WARNING, ERREUR import config from time import strftime +try: + sys.path.append('/usr/lib/mailman') + from Mailman.MailList import MailList + from Mailman.UserDesc import UserDesc + from Mailman.Errors import MMAlreadyAMember +except: + # Machine sans mailman, les ML ne seront pas reconfigurées + pass + + class del_user: """ Suppression des fichiers d'un compte utilisateur """ @@ -135,12 +145,18 @@ class ML_ens: def reconfigure(self): cprint(u'Inscription ML-ENS', 'gras') + mlist = MailList('com-ens') for mail in self.mails: anim('\t' + mail) - status, output = commands.getstatusoutput("echo '%s' | /usr/sbin/add_members -r - com-ens >/dev/null 2>&1" % mail) - if status: + try: + mlist.ApprovedAddMember(UserDesc(mail)) + except MMAlreadyAMember: + cprint(u"DÉJÀ INSCRIT", "jaune") + except: print ERREUR - if self.debug: - sys.stderr.write(output + '\n') + if self.debug: + traceback.print_exc() else: print OK + mlist.Save() + mlist.Unlock()