Gestion de certaines erreurs
This commit is contained in:
parent
43c7ab0514
commit
ffcdaf0551
1 changed files with 8 additions and 2 deletions
|
@ -39,7 +39,10 @@ def prise_etat(chbre):
|
||||||
return style(u"Aucune adresse connue", "violet")
|
return style(u"Aucune adresse connue", "violet")
|
||||||
bat = chbre[0].lower()
|
bat = chbre[0].lower()
|
||||||
chbre = chbre[1:]
|
chbre = chbre[1:]
|
||||||
|
try:
|
||||||
prise = gestion.annuaires_pg.chbre_prises(batiment=bat, chambre=chbre)
|
prise = gestion.annuaires_pg.chbre_prises(batiment=bat, chambre=chbre)
|
||||||
|
except gestion.annuaires_pg.ChbreNotFound:
|
||||||
|
return style(u"Chambre inconnue", "violet")
|
||||||
|
|
||||||
swid, port = int(prise[0]), int(prise[1:])
|
swid, port = int(prise[0]), int(prise[1:])
|
||||||
switch_name = "bat%s-%s.adm.crans.org" % (bat, swid)
|
switch_name = "bat%s-%s.adm.crans.org" % (bat, swid)
|
||||||
|
@ -51,7 +54,10 @@ def prise_etat(chbre):
|
||||||
lien = style(u"Prise %s%s virtuelle" % (bat, prise), "violet")
|
lien = style(u"Prise %s%s virtuelle" % (bat, prise), "violet")
|
||||||
return u", ".join([lien, cablage])
|
return u", ".join([lien, cablage])
|
||||||
|
|
||||||
|
try:
|
||||||
switch = hptools2.HPSwitch(switch_name)
|
switch = hptools2.HPSwitch(switch_name)
|
||||||
|
except hptools2.SwitchNotFound:
|
||||||
|
return style(u"Chambre inconnue", "violet")
|
||||||
vlan_list = switch.get_vlans(port)
|
vlan_list = switch.get_vlans(port)
|
||||||
|
|
||||||
vlans = u" " * (13 + len(chbre))
|
vlans = u" " * (13 + len(chbre))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue