Encore un patch Fred
darcs-hash:20040903194059-d1718-4419a0e74723574b538f2d2756954c74a830e807.gz
This commit is contained in:
parent
1ea62938a9
commit
bb318fc560
3 changed files with 30 additions and 17 deletions
|
@ -1,11 +1,11 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
|
||||
import sys, signal, os, commands, getopt
|
||||
import sys, signal, os, commands, getopt, smtplib
|
||||
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
|
||||
from ldap_crans import crans_ldap, crans, ann_scol
|
||||
from ldap_crans import crans_ldap, crans, ann_scol, smtpserv
|
||||
from lock import *
|
||||
from affich_tools import anim, cprint, OK, ERREUR, WARNING
|
||||
from time import localtime
|
||||
|
@ -24,7 +24,7 @@ make_lock('auto_generate')
|
|||
##### Options fournies ?
|
||||
try :
|
||||
if len(sys.argv) > 1 :
|
||||
options, arg = getopt.getopt(sys.argv[1:], '', ['quiet', 'home=', 'ML-ENS=', 'droits', 'switch=' , 'dhcp', 'dns', 'firewall' ])
|
||||
options, arg = getopt.getopt(sys.argv[1:], '', ['quiet', 'home=', 'mail_bienvenue=', 'ML-ENS=', 'droits', 'switch=' , 'dhcp', 'dns', 'firewall' ])
|
||||
else :
|
||||
options, arg = ( [],'')
|
||||
except getopt.error, msg :
|
||||
|
@ -73,6 +73,28 @@ if 'home' in to_do.keys() :
|
|||
if debug :
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
if 'mail_bienvenue' in to_do.keys() :
|
||||
if auto : db.services_to_restart('-mail_bienvenue')
|
||||
cprint('Envoi mail de bienvenue','gras')
|
||||
pas_fait = []
|
||||
for mail in to_do['mail_bienvenue'] :
|
||||
anim('\t' + mail)
|
||||
try :
|
||||
From = "respbats@crans.org"
|
||||
To = mail
|
||||
if To.find('@') == -1 : To += '@crans.org'
|
||||
conn=smtplib.SMTP(smtpserv)
|
||||
conn.sendmail(From, To , config.txt_mail_bienvenue % { 'From' : From, 'To' : To })
|
||||
conn.quit()
|
||||
print OK
|
||||
except Exception, c:
|
||||
print ERREUR
|
||||
pas_fait.append(mail)
|
||||
if debug :
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
if auto and pas_fait :
|
||||
db.services_to_restart('mail_bienvenue',pas_fait)
|
||||
|
||||
if 'ML-ENS' in to_do.keys() :
|
||||
cprint('Inscription ML-ENS','gras')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue