Commit 112f4304 authored by Daniel STAN's avatar Daniel STAN

wiki: AutoStatus en utf-8

parent 82804b79
......@@ -6,6 +6,18 @@ from commands import getstatusoutput,getoutput
def execute(macro, text) :
descriptions = {}
with open('/usr/scripts/var/autostatus/hosts', 'r') as f:
for line in f.readlines():
line = line.split(' ', 4)
host = line[0]
try:
dec = line[4].decode('utf-8', errors='ignore')
except IndexError:
dec = u"N/A"
dec = dec.strip()
descriptions[host] = u'%s (%s)' % (host, dec)
lines = open('/usr/scripts/var/local.status').readlines()
f = macro.formatter
......@@ -22,7 +34,7 @@ def execute(macro, text) :
line = lines[0].split(' ')
trucsdown += f.table_row(1)
trucsdown += f.table_cell(1,{'style':'background-color:lightgrey; color: black;'})
trucsdown += unicode(f.text('%s (%s)' % (line [0], getoutput("grep '^%s[^-.a-zA-Z]' /usr/scripts/var/autostatus/hosts | cut -d ' ' -f 5-" % line [0])) ), "iso-8859-15")
trucsdown += f.text(descriptions.get(line[0], line[0]))
trucsdown += f.table_cell(0)
# nombre de non réponse au ping
if int(line[1]) > 2 :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment