En fait, cela marche, j'avais pas vu le .encode tratre la fin...

darcs-hash:20051011104526-d1718-0a4fc6accad5f803001fd0b22361c7ddfde83466.gz
This commit is contained in:
bernat 2005-10-11 12:45:26 +02:00
parent a4b3685c8d
commit fcbf4c4755

View file

@ -20,10 +20,10 @@ def execute(macro, text) :
status = getstatusoutput('grep -v " 0 " /etc/autostatus/local.status') status = getstatusoutput('grep -v " 0 " /etc/autostatus/local.status')
if status[0] and status[0] != 256 : if status[0] and status[0] != 256 :
return Cellule(u'Impossible d\'analyser le fichier de status.'.encode('utf-8'),'yellow',macro.formatter) return Cellule(u'Impossible d\'analyser le fichier de status.','yellow',macro.formatter)
if not status[1].strip() : if not status[1].strip() :
return Cellule(u'Toutes les machines importantes sont up.'.encode('utf-8'),'lime',macro.formatter) return Cellule(u'Toutes les machines importantes sont up.','lime',macro.formatter)
lines = status[1].split('\n') lines = status[1].split('\n')
@ -35,18 +35,18 @@ def execute(macro, text) :
line = line.split(' ') line = line.split(' ')
code += f.table_row(1) code += f.table_row(1)
code += f.table_cell(1,{'style':'background-color:silver'}) code += f.table_cell(1,{'style':'background-color:silver'})
code += f.text('%s (%s)' % (line [0], getoutput("grep '%s' /etc/autostatus/hosts | cut -d ' ' -f 5-" % line [0])) ) code += f.text('%s (%s)' % (line [0], getoutput("grep '^%s' /etc/autostatus/hosts | cut -d ' ' -f 5-" % line [0])) )
code += f.table_cell(0) code += f.table_cell(0)
# nombre de non réponse au ping # nombre de non réponse au ping
if int(line[1]) > 2 : if int(line[1]) > 2 :
code += f.table_cell(1,{'style':'background-color:red'}) code += f.table_cell(1,{'style':'background-color:red'})
code += f.text(u'down'.encode('utf-8')) code += f.text(u'down')
else : else :
code += f.table_cell(1,{'style':'background-color:blue'}) code += f.table_cell(1,{'style':'background-color:blue'})
code += f.text(u'etat incertain'.encode('utf-8')) code += f.text(u'état incertain')
code += f.table_cell(0) code += f.table_cell(0)
code += f.table_row(0) code += f.table_row(0)
code += f.table(0) code += f.table(0)
return code.encode('iso-8859-15') return code