[wiki/macro/HostStatus.py] Gros hack pour afficher par categories
darcs-hash:20081117104006-bd074-56aa15fe8b04d319066a756d7881a7b569e5c093.gz
This commit is contained in:
parent
e99f189ec2
commit
9a4383c723
1 changed files with 41 additions and 29 deletions
|
@ -1,5 +1,6 @@
|
||||||
# -*- coding: iso-8859-1 -*-
|
# -*- coding: iso-8859-1 -*-
|
||||||
|
|
||||||
|
import re
|
||||||
from commands import getstatusoutput,getoutput
|
from commands import getstatusoutput,getoutput
|
||||||
|
|
||||||
def Cellule(texte, couleur, f) :
|
def Cellule(texte, couleur, f) :
|
||||||
|
@ -17,21 +18,32 @@ def Cellule(texte, couleur, f) :
|
||||||
|
|
||||||
def execute(macro, text) :
|
def execute(macro, text) :
|
||||||
|
|
||||||
status = getstatusoutput('grep -v " 0 " /etc/autostatus/local.status')
|
lines = open('/etc/autostatus/local.status').readlines()
|
||||||
|
|
||||||
if status[0] and status[0] != 256 :
|
# if status[0] and status[0] != 256 :
|
||||||
return Cellule(u'Impossible d\'analyser le fichier de status.','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.','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')
|
||||||
|
|
||||||
f = macro.formatter
|
f = macro.formatter
|
||||||
code = ''
|
code = ''
|
||||||
|
code += f.heading(1,3)
|
||||||
|
code += 'Autostatus des machines'
|
||||||
|
code += f.heading(0,3)
|
||||||
code += f.table(1)
|
code += f.table(1)
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
if re.match('dummy_host_\d+ 0 \n', line):
|
||||||
|
if line == 'dummy_host_9 0 \n':
|
||||||
|
code += f.table(0)
|
||||||
|
code += f.heading(1,3)
|
||||||
|
code += 'Autostatus des bornes wifi'
|
||||||
|
code += f.heading(0,3)
|
||||||
|
code += f.table(1)
|
||||||
|
if not re.search(' 0 ', line):
|
||||||
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'})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue