43 lines
1,004 B
Python
Executable file
43 lines
1,004 B
Python
Executable file
#! /usr/bin/env python
|
|
# -*- coding: iso-8859-15 -*-
|
|
|
|
# syntaxe : chambre-on-off.py A101d on
|
|
# chambre-on-off.py A101d off
|
|
|
|
import sys
|
|
sys.path.append("/usr/scripts/gestion/")
|
|
|
|
# recherche des coordonnées de la chambre
|
|
from annuaires import chbre_prises
|
|
chbre = sys.argv[1].lower()
|
|
bat = chbre[0]
|
|
prise = int(chbre_prises[bat][chbre[1:]][1:])
|
|
switch = "bat" + bat + "-" + chbre_prises[bat][chbre[1:]][0]
|
|
cmd = sys.argv[2].lower()
|
|
|
|
# connecion au switch
|
|
from hptools import hpswitch
|
|
sw = hpswitch(switch)
|
|
|
|
# affichage des infos
|
|
print "chbre : " + chbre
|
|
print "switch : " + switch
|
|
print "prise : " + str(prise)
|
|
if sw.is_enable(prise):
|
|
print "old statut : on"
|
|
else:
|
|
print "old statut : off"
|
|
|
|
# modification du statut
|
|
if cmd == "off":
|
|
print "action : disable"
|
|
sw.disable(prise)
|
|
else:
|
|
print "action : enable"
|
|
sw.enable(prise)
|
|
|
|
# affichage du nouveau statut
|
|
if sw.is_enable(prise):
|
|
print "new statut : on"
|
|
else:
|
|
print "new statut : off"
|