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,32 +132,42 @@ exit
""" Recontigure la chambre fournie chambre """
try :
bat = chbre[0].lower()
prise = sw_chbre(chbre)
prise.reconfigure() # Vitesse et nom (juste au cas ou ca aurait changé)
if bat in bat_switchs :
prise = sw_chbre(chbre)
prise.reconfigure() # Vitesse et nom (juste au cas ou ca aurait changé)
else :
class prise_non_manageable :
def __init__(self,chbre) :
self.chbre = chbre
def __mail(sujet) :
To = "clef%s@crans.org" % self.chbre[0].lower()
From = To
conn=smtplib.SMTP('localhost')
txt_mail = "From: Crans scripts <%(From)s>\n"
txt_mail+= "To: %(To)s\n"
txt_mail+= "Subject: (CRANS) %s\n\nMerci." % sujet
conn.sendmail(From, To , txt_mail % { 'From' : From, 'To' : To })
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']
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
prise.enable()
else :
# Il faut désactiver la prise
anim('\tdésactivation chbre %s' % chbre)
if bat in bat_switchs : prise.disable()
else : sujet = "Chambre %s à débrancher." % chbre
if sujet :
# Il faut envoyer un mail
To = "clef%s@crans.org" % bat
From = To
conn=smtplib.SMTP('localhost')
txt_mail = "From: Crans scripts <%(From)s>\n"
txt_mail+= "To: %(To)s\n"
txt_mail+= "Subject: (CRANS) %s\n\nMerci." % sujet
conn.sendmail(From, To , txt_mail % { 'From' : From, 'To' : To })
conn.quit()
prise.disable()
print OK
except :
print ERREUR