From 3ed8efdd2611f22d9a318f4b3fcbec0120edd65a Mon Sep 17 00:00:00 2001 From: glondu Date: Thu, 6 Apr 2006 05:10:54 +0200 Subject: [PATCH] Mise en forme. darcs-hash:20060406031054-68412-9f7f19f8e8c05e3e550c312a612e89e0c7deda2c.gz --- gestion/gen_confs/adherents.py | 74 ++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/gestion/gen_confs/adherents.py b/gestion/gen_confs/adherents.py index 3b1a7bf4..e4c8f3eb 100755 --- a/gestion/gen_confs/adherents.py +++ b/gestion/gen_confs/adherents.py @@ -15,7 +15,7 @@ class del_user: debug = True - def __init__(self,args): + def __init__(self, args): self.args = args def reconfigure(self): @@ -57,84 +57,90 @@ class del_user: class home: debug = True - def __init__(self,args) : + + def __init__(self, args): self.args = args - def reconfigure(self) : + + def reconfigure(self): cprint(u'Création home', 'gras') - for args in self.args : + for args in self.args: anim('\t' + args) try: home, uid, login = args.split(',') ### Home - if not os.path.exists(home) : + if not os.path.exists(home): # Le home n'existe pas os.mkdir(home, 0755) - os.chown(home, int(uid) ,config.gid) - elif os.path.isdir(home) : - # Il y un répertoire existant + os.chown(home, int(uid), config.gid) + elif os.path.isdir(home): + # Il y un répertoire existant # Bon UID ? stat = os.stat(home) - if stat[4] != int(uid) or stat[5] != config.gid : - # Le home n'est pas à la bonne personne + if stat[4] != int(uid) or stat[5] != config.gid: + # Le home n'est pas pas à la bonne personne raise OSError('home existant') ### Quota status, output = commands.getstatusoutput('/usr/sbin/edquota -p pauget %s' % login ) - if status : + if status: print WARNING - if self.debug : + if self.debug: sys.stderr.write(output+'\n') - else : + else: print OK ### Mail os.mkdir(home + '/Mail', 0700) - os.chown(home + '/Mail', int(uid) ,config.gid) - os.mkdir('/var/mail/' + login,0770) - os.chown('/var/mail/' + login, int(uid) ,8) + os.chown(home + '/Mail', int(uid), config.gid) + os.mkdir('/var/mail/' + login, 0770) + os.chown('/var/mail/' + login, int(uid), 8) - except : + except: print ERREUR - if self.debug : + if self.debug: import traceback traceback.print_exc() -class mail_bienvenue : + +class mail_bienvenue: debug = True - def __init__(self,mails) : + + def __init__(self, mails): self.mails = mails - def reconfigure(self) : + def reconfigure(self): cprint(u'Envoi mail de bienvenue', 'gras') - for mail in self.mails : + for mail in self.mails: anim('\t' + mail) try: From = "respbats@crans.org" To = mail - if To.find('@') == -1 : To += '@crans.org' + if To.find('@') == -1: To += '@crans.org' conn=smtplib.SMTP('localhost') - conn.sendmail(From, To , config.txt_mail_bienvenue % { 'From' : From, 'To' : To }) + conn.sendmail(From, To, config.txt_mail_bienvenue % { 'From': From, 'To': To }) conn.quit() print OK except Exception, c: print ERREUR - if self.debug : + if self.debug: import traceback traceback.print_exc() + -class ML_ens : +class ML_ens: debug = True - def __init__(self,mails) : + + def __init__(self, mails): self.mails = mails - def reconfigure(self) : + def reconfigure(self): cprint(u'Inscription ML-ENS', 'gras') - for mail in self.mails : - anim('\t'+mail) + 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 : + if status: print ERREUR - if self.debug : - sys.stderr.write(output+'\n') - else : + if self.debug: + sys.stderr.write(output + '\n') + else: print OK