wiki: AutoStatus en utf-8
This commit is contained in:
parent
82804b7924
commit
112f43046c
1 changed files with 13 additions and 1 deletions
|
@ -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 :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue