[wifi/{bornes.py,status.py}] légères modifications maintenant que gordon est le routeur wifi
darcs-hash:20091109025242-bd074-2a7b80e68944e1a6e949eedfac93dd94a01ab4ef.gz
This commit is contained in:
parent
61d31e04a0
commit
c541996784
2 changed files with 21 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- encoding: iso-8859-15 -*-
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
|
||||
# Génération d'un fichier XML indiquant le status des bornes
|
||||
|
||||
|
@ -25,6 +25,7 @@ xml_bornes.setAttribute(u"date",time.strftime("%c"))
|
|||
|
||||
# On récupère l'ensemble des bornes
|
||||
bornes = l.search('host=*.wifi.crans.org&canal=*')['borneWifi']
|
||||
bornes.sort(cmp=(lambda x, y: cmp(x.nom(), y.nom())))
|
||||
|
||||
canaux = bornes_canal()
|
||||
clients = bornes_clients()
|
||||
|
@ -32,7 +33,6 @@ uptimes = bornes_uptime()
|
|||
|
||||
for b in bornes:
|
||||
infos = filter(lambda x: not x.startswith("<"), b.info())
|
||||
|
||||
if not infos or b.nom().split('.')[0]=="non-configure":
|
||||
# Rien à propos de cette borne...
|
||||
continue
|
||||
|
@ -40,7 +40,7 @@ for b in bornes:
|
|||
# Est-ce un hotspot ?
|
||||
hotspot = b.hotspot() and 1 or 0
|
||||
# Est-ce que la borne est up ?
|
||||
if os.system("/usr/local/sbin/fping -q %s || /usr/local/sbin/fping -q %s" % ((b.nom(),)*2)) == 0:
|
||||
if os.system("/usr/sbin/fping -q %s 2> /dev/null" % b.nom()) == 0:
|
||||
up = 1
|
||||
else:
|
||||
up = 0
|
||||
|
@ -55,35 +55,37 @@ for b in bornes:
|
|||
xml_desc.appendChild(status.createTextNode(infos[0]))
|
||||
#xml_desc.appendChild(status.createTextNode(u"Description pas compatible unicode/ascii"))
|
||||
xml_borne.appendChild(xml_desc)
|
||||
|
||||
xml_mac=status.createElement(u"mac")
|
||||
xml_mac.appendChild(status.createTextNode(b.mac2()))
|
||||
xml_borne.appendChild(xml_mac)
|
||||
|
||||
|
||||
# Certains résultats (ragnarok) n'ont pas tous les champs.
|
||||
if (canaux.has_key(nom)):
|
||||
xml_canal=status.createElement(u"canal")
|
||||
xml_canal.appendChild(status.createTextNode(unicode(int('0' + canaux[nom]))))
|
||||
try: canal = unicode(int(canaux[nom]))
|
||||
except TypeError: canal = u'Inconnu'
|
||||
xml_canal.appendChild(status.createTextNode(canal))
|
||||
xml_borne.appendChild(xml_canal)
|
||||
|
||||
|
||||
if (clients.has_key(nom)):
|
||||
xml_clients=status.createElement(u"clients")
|
||||
xml_clients.appendChild(status.createTextNode(unicode(int('0' + clients[nom]))))
|
||||
try: client = unicode(int(clients[nom]))
|
||||
except TypeError: client = u'Inconnu'
|
||||
xml_clients.appendChild(status.createTextNode(client))
|
||||
xml_borne.appendChild(xml_clients)
|
||||
|
||||
|
||||
if (uptimes.has_key(nom)):
|
||||
xml_uptime=status.createElement(u"uptime")
|
||||
xml_uptime.appendChild(status.createTextNode(unicode(uptimes[nom])))
|
||||
xml_borne.appendChild(xml_uptime)
|
||||
|
||||
|
||||
|
||||
position = b.position()
|
||||
if position:
|
||||
xml_position=status.createElement(u"position")
|
||||
xml_position.setAttribute(u"x",unicode(position[1]))
|
||||
xml_position.setAttribute(u"y",unicode(position[0]))
|
||||
xml_borne.appendChild(xml_position)
|
||||
|
||||
|
||||
xml_bornes.appendChild(xml_borne)
|
||||
|
||||
|
||||
print (status.toxml().encode("UTF-8"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue