diff --git a/gestion/gen_confs/switchs.py b/gestion/gen_confs/switchs.py index 56a0b4e4..631c649e 100755 --- a/gestion/gen_confs/switchs.py +++ b/gestion/gen_confs/switchs.py @@ -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