envoi de mails pour :
- la modification des droits d'un adhrent - la modification du firewall concernant une machine - la modification d'un serveur la fonction utilise pour envoyer des mails est dans mail.py pour le firewall je ne sait pas quoi gnrer comme execption si j'arrive pas envoyerr de mail, donc ca part la trappe si komaz n'arrive pas crire le mail darcs-hash:20050221194135-4ec08-9ef761d782311a90d0d6caa495b6862ada6634b9.gz
This commit is contained in:
parent
91f6ae68cc
commit
e1d596eed7
4 changed files with 95 additions and 58 deletions
|
@ -218,18 +218,23 @@ class droits(crans_ldap,gen_config) :
|
|||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
self.anim = anim('\tenvoi de mails à roots')
|
||||
self.anim = anim('\tenvoi d\'un mail à roots')
|
||||
try :
|
||||
self.mail(self.uids)
|
||||
from mail import mail_details
|
||||
adherents = []
|
||||
for uid in self.uids :
|
||||
adherents += self.search('uid=%s' % uid)['adherent']
|
||||
mail_details(adherents, Subject = 'Modification des droits d\'un adherent')
|
||||
self.anim.reinit()
|
||||
print OK
|
||||
except :
|
||||
self.services_to_restart('droits',self.uids)
|
||||
self.anim.reinit()
|
||||
print ERREUR
|
||||
if self.debug :
|
||||
if self.debug :
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
traceback.print_exc()
|
||||
|
||||
elif gethostname().split(".")[0] == 'nectaris':
|
||||
self.anim = anim('\tconfiguration master.passwd')
|
||||
try:
|
||||
|
@ -243,31 +248,6 @@ class droits(crans_ldap,gen_config) :
|
|||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
def mail (self, uids) :
|
||||
""" Envoi un mail à roots pour dire que certains droits ont changé """
|
||||
|
||||
# base du mail
|
||||
From = "roots@crans.org"
|
||||
To = "roots@crans.org"
|
||||
base_txt_mail = """From: %(From)s
|
||||
To: %(To)s
|
||||
Subject: Modifications des droits d'un adhérent
|
||||
|
||||
%(Texte)s"""
|
||||
|
||||
# boucle pour chaque adhérent modifié
|
||||
for uid in uids :
|
||||
try :
|
||||
adh = self.search('uid=%s' % uid)['adherent']
|
||||
|
||||
if len(adh):
|
||||
adh = adh[0]
|
||||
conn=smtplib.SMTP(smtpserv)
|
||||
conn.sendmail(From, To , base_txt_mail % { 'From' : From, 'To' : To, 'Texte' : adher_details(adh).encode('iso8859-15') })
|
||||
conn.quit()
|
||||
except :
|
||||
self.services_to_restart('droits',[uid])
|
||||
|
||||
if __name__ == '__main__' :
|
||||
if '-h' in sys.argv or '--help' in sys.argv or len(sys.argv) == 1 :
|
||||
print "%s <switch>" % sys.argv[0].split('/')[-1].split('.')[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue