C'est plus propre comme cela.

darcs-hash:20041005181607-41617-c7a996b5708a1b84e25039e3c23117f94b9626dc.gz
This commit is contained in:
pauget 2004-10-05 20:16:07 +02:00
parent 5bd806ea3b
commit af963b9451

View file

@ -132,25 +132,16 @@ exit
""" Recontigure la chambre fournie chambre """ """ Recontigure la chambre fournie chambre """
try : try :
bat = chbre[0].lower() bat = chbre[0].lower()
if bat in bat_switchs :
prise = sw_chbre(chbre) prise = sw_chbre(chbre)
prise.reconfigure() # Vitesse et nom (juste au cas ou ca aurait changé) prise.reconfigure() # Vitesse et nom (juste au cas ou ca aurait changé)
a = self.db.search('chbre=%s&paiement=ok' % chbre)
a = a['adherent'] + a['club']
sujet = ''
if a and 'bloq' not in a[0].blacklist_actif() :
# Il faut activer la prise
anim('\tactivation chbre %s' % chbre)
if bat in bat_switchs : prise.enable()
else : sujet = "Chambre %s à brancher." % chbre
else : else :
# Il faut désactiver la prise class prise_non_manageable :
anim('\tdésactivation chbre %s' % chbre) def __init__(self,chbre) :
if bat in bat_switchs : prise.disable() self.chbre = chbre
else : sujet = "Chambre %s à débrancher." % chbre
if sujet : def __mail(sujet) :
# Il faut envoyer un mail To = "clef%s@crans.org" % self.chbre[0].lower()
To = "clef%s@crans.org" % bat
From = To From = To
conn=smtplib.SMTP('localhost') conn=smtplib.SMTP('localhost')
txt_mail = "From: Crans scripts <%(From)s>\n" txt_mail = "From: Crans scripts <%(From)s>\n"
@ -158,6 +149,25 @@ exit
txt_mail+= "Subject: (CRANS) %s\n\nMerci." % sujet txt_mail+= "Subject: (CRANS) %s\n\nMerci." % sujet
conn.sendmail(From, To , txt_mail % { 'From' : From, 'To' : To }) conn.sendmail(From, To , txt_mail % { 'From' : From, 'To' : To })
conn.quit() conn.quit()
def disable() :
self.__mail("Chambre %s à débrancher." % self.chbre)
def enable() :
self.__mail("Chambre %s à brancher." % self.chbre)
prise=prise_non_manageable(chbre)
a = self.db.search('chbre=%s&paiement=ok' % chbre)
a = a['adherent'] + a['club']
if a and 'bloq' not in a[0].blacklist_actif() :
# Il faut activer la prise
anim('\tactivation chbre %s' % chbre)
prise.enable()
else :
# Il faut désactiver la prise
anim('\tdésactivation chbre %s' % chbre)
prise.disable()
print OK print OK
except : except :
print ERREUR print ERREUR