Mise en forme.

darcs-hash:20060406031054-68412-9f7f19f8e8c05e3e550c312a612e89e0c7deda2c.gz
This commit is contained in:
glondu 2006-04-06 05:10:54 +02:00
parent cd8bafd791
commit 3ed8efdd26

View file

@ -15,7 +15,7 @@ class del_user:
debug = True debug = True
def __init__(self,args): def __init__(self, args):
self.args = args self.args = args
def reconfigure(self): def reconfigure(self):
@ -57,84 +57,90 @@ class del_user:
class home: class home:
debug = True debug = True
def __init__(self,args) :
def __init__(self, args):
self.args = args self.args = args
def reconfigure(self) :
def reconfigure(self):
cprint(u'Création home', 'gras') cprint(u'Création home', 'gras')
for args in self.args : for args in self.args:
anim('\t' + args) anim('\t' + args)
try: try:
home, uid, login = args.split(',') home, uid, login = args.split(',')
### Home ### Home
if not os.path.exists(home) : if not os.path.exists(home):
# Le home n'existe pas # Le home n'existe pas
os.mkdir(home, 0755) os.mkdir(home, 0755)
os.chown(home, int(uid) ,config.gid) os.chown(home, int(uid), config.gid)
elif os.path.isdir(home) : elif os.path.isdir(home):
# Il y un répertoire existant # Il y un répertoire existant
# Bon UID ? # Bon UID ?
stat = os.stat(home) stat = os.stat(home)
if stat[4] != int(uid) or stat[5] != config.gid : if stat[4] != int(uid) or stat[5] != config.gid:
# Le home n'est pas à la bonne personne # Le home n'est pas pas à la bonne personne
raise OSError('home existant') raise OSError('home existant')
### Quota ### Quota
status, output = commands.getstatusoutput('/usr/sbin/edquota -p pauget %s' % login ) status, output = commands.getstatusoutput('/usr/sbin/edquota -p pauget %s' % login )
if status : if status:
print WARNING print WARNING
if self.debug : if self.debug:
sys.stderr.write(output+'\n') sys.stderr.write(output+'\n')
else : else:
print OK print OK
### Mail ### Mail
os.mkdir(home + '/Mail', 0700) os.mkdir(home + '/Mail', 0700)
os.chown(home + '/Mail', int(uid) ,config.gid) os.chown(home + '/Mail', int(uid), config.gid)
os.mkdir('/var/mail/' + login,0770) os.mkdir('/var/mail/' + login, 0770)
os.chown('/var/mail/' + login, int(uid) ,8) os.chown('/var/mail/' + login, int(uid), 8)
except : except:
print ERREUR print ERREUR
if self.debug : if self.debug:
import traceback import traceback
traceback.print_exc() traceback.print_exc()
class mail_bienvenue :
class mail_bienvenue:
debug = True debug = True
def __init__(self,mails) :
def __init__(self, mails):
self.mails = mails self.mails = mails
def reconfigure(self) : def reconfigure(self):
cprint(u'Envoi mail de bienvenue', 'gras') cprint(u'Envoi mail de bienvenue', 'gras')
for mail in self.mails : for mail in self.mails:
anim('\t' + mail) anim('\t' + mail)
try: try:
From = "respbats@crans.org" From = "respbats@crans.org"
To = mail To = mail
if To.find('@') == -1 : To += '@crans.org' if To.find('@') == -1: To += '@crans.org'
conn=smtplib.SMTP('localhost') 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() conn.quit()
print OK print OK
except Exception, c: except Exception, c:
print ERREUR print ERREUR
if self.debug : if self.debug:
import traceback import traceback
traceback.print_exc() traceback.print_exc()
class ML_ens : class ML_ens:
debug = True debug = True
def __init__(self,mails) :
def __init__(self, mails):
self.mails = mails self.mails = mails
def reconfigure(self) : def reconfigure(self):
cprint(u'Inscription ML-ENS', 'gras') cprint(u'Inscription ML-ENS', 'gras')
for mail in self.mails : for mail in self.mails:
anim('\t'+mail) anim('\t' + mail)
status, output = commands.getstatusoutput("echo '%s' | /usr/sbin/add_members -r - com-ens >/dev/null 2>&1" % 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 print ERREUR
if self.debug : if self.debug:
sys.stderr.write(output+'\n') sys.stderr.write(output + '\n')
else : else:
print OK print OK