on envoi un mail roots quand il y a des modifications dans les droits
(en envoi le whos de l'adhrent) darcs-hash:20050211103107-4ec08-82d4904218d29aef22e9713bfdcb25a45558036c.gz
This commit is contained in:
parent
2e766deefb
commit
e19194147e
3 changed files with 47 additions and 8 deletions
|
@ -1,12 +1,13 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
|
||||
import sys, signal, os
|
||||
import sys, signal, os, smtplib
|
||||
|
||||
# Imports pour LDAP
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
from gen_confs import gen_config, anim, cprint, OK, ERREUR
|
||||
from ldap_crans import crans_ldap, crans, preattr, ldap
|
||||
from ldap_crans import crans_ldap, crans, preattr, ldap, smtpserv
|
||||
from whos import adher_details
|
||||
|
||||
from socket import gethostname
|
||||
|
||||
|
@ -37,7 +38,7 @@ class droits(crans_ldap,gen_config) :
|
|||
'respbats' : [ u'Câbleur', u'Nounou' ],
|
||||
'+moderateurs' : [ u'Modérateur' ],
|
||||
'+disconnect' : [ u'Déconnecteur' ] }
|
||||
|
||||
|
||||
def restart(s) :
|
||||
# Rien à faire
|
||||
pass
|
||||
|
@ -216,6 +217,19 @@ class droits(crans_ldap,gen_config) :
|
|||
if self.debug :
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
self.anim = anim('\tenvoi de mails à roots')
|
||||
try :
|
||||
self.mail(self.uids)
|
||||
self.anim.reinit()
|
||||
print OK
|
||||
except :
|
||||
self.anim.reinit()
|
||||
print ERREUR
|
||||
if self.debug :
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
elif gethostname().split(".")[0] == 'nectaris':
|
||||
self.anim = anim('\tconfiguration master.passwd')
|
||||
try:
|
||||
|
@ -228,7 +242,31 @@ class droits(crans_ldap,gen_config) :
|
|||
if self.debug :
|
||||
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 :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue