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
|
#! /usr/bin/env python
|
||||||
# -*- coding: iso-8859-15 -*-
|
# -*- coding: iso-8859-15 -*-
|
||||||
|
|
||||||
import sys, signal, os
|
import sys, signal, os, smtplib
|
||||||
|
|
||||||
# Imports pour LDAP
|
# Imports pour LDAP
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from gen_confs import gen_config, anim, cprint, OK, ERREUR
|
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
|
from socket import gethostname
|
||||||
|
|
||||||
|
@ -216,6 +217,19 @@ class droits(crans_ldap,gen_config) :
|
||||||
if self.debug :
|
if self.debug :
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
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':
|
elif gethostname().split(".")[0] == 'nectaris':
|
||||||
self.anim = anim('\tconfiguration master.passwd')
|
self.anim = anim('\tconfiguration master.passwd')
|
||||||
try:
|
try:
|
||||||
|
@ -229,6 +243,30 @@ class droits(crans_ldap,gen_config) :
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
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 __name__ == '__main__' :
|
||||||
if '-h' in sys.argv or '--help' in sys.argv or len(sys.argv) == 1 :
|
if '-h' in sys.argv or '--help' in sys.argv or len(sys.argv) == 1 :
|
||||||
|
|
|
@ -242,10 +242,11 @@ if hostname == 'zamok':
|
||||||
try:
|
try:
|
||||||
from gen_confs.droits import droits
|
from gen_confs.droits import droits
|
||||||
a = droits()
|
a = droits()
|
||||||
|
a.uids = to_do['droits']
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto : db.services_to_restart('droits')
|
if auto : db.services_to_restart('droits',to_do['droits'])
|
||||||
|
|
||||||
if 'blacklist_upload' in to_do.keys() :
|
if 'blacklist_upload' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-blacklist_upload')
|
if auto : db.services_to_restart('-blacklist_upload')
|
||||||
|
|
|
@ -197,7 +197,7 @@ class crans_ldap :
|
||||||
'club' : [ 'nom', 'chbre' ] }
|
'club' : [ 'nom', 'chbre' ] }
|
||||||
|
|
||||||
# Champs de recherche pour la recherche manuelle (en plus de la recherche auto)
|
# Champs de recherche pour la recherche manuelle (en plus de la recherche auto)
|
||||||
non_auto_search_champs = { 'adherent' : [ 'etudes', 'paiement', 'carteEtudiant', 'aid' , 'postalAddress', 'historique' ,'blacklist', 'droits', 'uidNumber' ], \
|
non_auto_search_champs = { 'adherent' : [ 'etudes', 'paiement', 'carteEtudiant', 'aid' , 'postalAddress', 'historique' ,'blacklist', 'droits', 'uidNumber', 'uid' ], \
|
||||||
'machine' : [ 'mid' , 'ipsec', 'historique', 'blacklist' , 'puissance', 'canal', 'portTCPin', 'portTCPout', 'portUDPin', 'portUDPout' , 'prise' ] ,
|
'machine' : [ 'mid' , 'ipsec', 'historique', 'blacklist' , 'puissance', 'canal', 'portTCPin', 'portTCPout', 'portUDPin', 'portUDPout' , 'prise' ] ,
|
||||||
'club' : [ 'cid' , 'responsable', 'paiement', 'historique', 'blacklist'] }
|
'club' : [ 'cid' , 'responsable', 'paiement', 'historique', 'blacklist'] }
|
||||||
|
|
||||||
|
@ -1183,7 +1183,7 @@ class base_proprietaire(base_classes_crans) :
|
||||||
|
|
||||||
# Modif des droits ?
|
# Modif des droits ?
|
||||||
if 'droits' in self.modifs :
|
if 'droits' in self.modifs :
|
||||||
self.services_to_restart('droits')
|
self.services_to_restart('droits',[self._data['uid']])
|
||||||
|
|
||||||
# Remise à zero
|
# Remise à zero
|
||||||
self.modifs=[]
|
self.modifs=[]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue