Macro qui affiche la liste des bornes avec leur description. Les informations
sont prise dans status.xml. darcs-hash:20060423122146-9e428-28f556c01f559da753b9fb1b0f73b136986653cf.gz
This commit is contained in:
parent
4977849bb6
commit
15c57389f9
1 changed files with 74 additions and 0 deletions
74
wiki/macro/InfosBornes.py
Executable file
74
wiki/macro/InfosBornes.py
Executable file
|
@ -0,0 +1,74 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- encoding: iso-8859-15 -*-
|
||||
|
||||
# Génération d'un fichier XML indiquant le status des bornes
|
||||
|
||||
import sys
|
||||
import os
|
||||
import time, urllib2
|
||||
import xml.dom.minidom
|
||||
|
||||
def execute(macro, text):
|
||||
f=macro.formatter
|
||||
|
||||
# ouverture du fichier d'info et parsage
|
||||
try:
|
||||
#os.putenv("http_proxy", "http://proxy.crans.org:3128")
|
||||
status=xml.dom.minidom.parseString(urllib2.urlopen("https://wifi.crans.org/status.xml").read())
|
||||
except:
|
||||
return f.text(u"Impossible d'accéder aux informations des bornes")
|
||||
|
||||
# On récupère l'ensemble des bornes
|
||||
bornes = status.childNodes[0]
|
||||
code = f.text(u"Mise à jour le "+bornes.getAttribute("date"))
|
||||
code += f.linebreak(0)
|
||||
|
||||
code += f.table(1)
|
||||
|
||||
code += f.table_row(1)
|
||||
for nom_col in [u"nom",u"hotspot",u"up",u"description",u"clients",u"mac wifi",u"canal",u"uptime",u"x",u"y"]:
|
||||
code += f.table_cell(1)
|
||||
code += f.text(nom_col)
|
||||
code += f.table_cell(0)
|
||||
code += f.table_row(0)
|
||||
|
||||
|
||||
for b in bornes.childNodes:
|
||||
code += f.table_row(1)
|
||||
|
||||
code += f.table_cell(1)
|
||||
code += f.text(b.getAttribute(u"nom"))
|
||||
code += f.table_cell(0)
|
||||
|
||||
dico={u"hotspot" : {u"1" : u"+" , u"0" : u""},
|
||||
u"up" : {u"1" : u"" , u"0": u"!"}}
|
||||
|
||||
for nom_attribut in [u"hotspot",u"up"]:
|
||||
code += f.table_cell(1)
|
||||
code += f.text(dico[nom_attribut][b.getAttribute(nom_attribut)])
|
||||
code += f.table_cell(0)
|
||||
|
||||
for tag in [u'description', u"clients",u"mac",u"canal",u"uptime"]:
|
||||
code += f.table_cell(1)
|
||||
if (b.getElementsByTagName(tag)!=[]):
|
||||
code += f.text(b.getElementsByTagName(tag)[0].firstChild.data)
|
||||
else:
|
||||
code += f.text(u"")
|
||||
code += f.table_cell(0)
|
||||
if (b.getElementsByTagName(u"position")!=[]):
|
||||
for nom_attribut in [u'x',u'y']:
|
||||
code += f.table_cell(1)
|
||||
code += f.text(b.getElementsByTagName(u"position")[0].getAttribute(nom_attribut))
|
||||
code += f.table_cell(0)
|
||||
else:
|
||||
code += f.table_cell(1)
|
||||
code += f.text(u"")
|
||||
code += f.table_cell(0)
|
||||
code += f.table_cell(1)
|
||||
code += f.text(u"")
|
||||
code += f.table_cell(0)
|
||||
|
||||
code += f.table_row(0)
|
||||
|
||||
code += f.table(0)
|
||||
return code
|
Loading…
Add table
Add a link
Reference in a new issue