diff --git a/wiki-lenny/local/macro/EtatCommutationSecours.py b/wiki-lenny/local/macro/EtatCommutationSecours.py
new file mode 100644
index 00000000..4efcc9de
--- /dev/null
+++ b/wiki-lenny/local/macro/EtatCommutationSecours.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+
+def Cellule(texte, couleur, f) :
+ """
+ Retourne le code HTML d'une cellule formattée aver le formatter f
+ """
+ code = f.table(1)
+ code += f.table_row(1)
+ code += f.table_cell(1,{'style':'background-color:%s' % couleur })
+ code += f.text(texte)
+ code += f.table_cell(0)
+ code += f.table_row(0)
+ code += f.table(0)
+ return code
+
+def execute(macro, text) :
+ try :
+ f = open('/usr/scripts/secours/etat_maitre')
+ f.readline()
+ if f.readline().strip() == 'auto' :
+ return "" #Cellule('La commutation automatique de l\'état est activée.','lime',macro.formatter)
+ else :
+ return Cellule(u'La commutation automatique de l\'état a été désactivée.','red',macro.formatter)
+ except :
+ return Cellule(u'Impossible de déterminer le type de commutation.','yellow',macro.formatter)
diff --git a/wiki-lenny/local/macro/EtatSecours.py b/wiki-lenny/local/macro/EtatSecours.py
new file mode 100644
index 00000000..e2cc88e1
--- /dev/null
+++ b/wiki-lenny/local/macro/EtatSecours.py
@@ -0,0 +1,24 @@
+# -*- coding: iso-8859-1 -*-
+
+def Cellule(texte, couleur, f) :
+ """
+ Retourne le code HTML d'une cellule formattée aver le formatter f
+ """
+ code = f.table(1)
+ code += f.table_row(1)
+ code += f.table_cell(1,{'style':'background-color:%s' % couleur })
+ code += f.text(texte)
+ code += f.table_cell(0)
+ code += f.table_row(0)
+ code += f.table(0)
+ return code
+
+def execute(macro, text) :
+ try :
+ f = open('/usr/scripts/secours/etat_maitre')
+ if f.readline().strip() == 'normal' :
+ return Cellule('Nous sommes actuellement en connexion normale.','lime',macro.formatter)
+ else :
+ return Cellule('Nous sommes actuellement en connexion de secours.','red',macro.formatter)
+ except :
+ return Cellule('Impossible de déterminer l\'état de la connexion.','yellow',macro.formatter)
diff --git a/wiki-lenny/local/macro/Gravatar.py b/wiki-lenny/local/macro/Gravatar.py
new file mode 100644
index 00000000..c3bc1b13
--- /dev/null
+++ b/wiki-lenny/local/macro/Gravatar.py
@@ -0,0 +1,22 @@
+# -*- coding: iso-8859-1 -*-
+"""
+ MoinMoin - Gravatar Macro
+ Gregoire Detrez, 2007
+ v 0.0.1
+ You can include a gravatar image by using this macro
+ [[Gravatar(name@exemple.com)]]
+"""
+
+def execute(macro, text):
+ import md5
+
+ parseargs = text.split(',')
+ if len(parseargs)<2:
+ return 'MailTo macro must have at least two arguments'
+ emailname, emailurl= parseargs[:2]
+ email = emailname.strip() + "@" + emailurl.strip()
+
+ user_id = md5.md5( email.strip() ).hexdigest()
+ url = 'http://www.gravatar.com/avatar.php?gravatar_id=%s&size=80' % user_id
+ html = "
+ Error: macro ProgressBar: %s
+ " % url
+ return html
diff --git a/wiki-lenny/local/macro/ImageLink.py b/wiki-lenny/local/macro/ImageLink.py
new file mode 100644
index 00000000..e280adfd
--- /dev/null
+++ b/wiki-lenny/local/macro/ImageLink.py
@@ -0,0 +1,173 @@
+# -*- coding: iso-8859-1 -*-
+"""
+ MoinMoin - ImageLink Macro
+
+ PURPOSE:
+ This macro is used to set a link as WikiName for an attached image. Optional the size of the
+ image could be adjusted. If no WikiName is given the attachment is linked to the image itselfs.
+
+ CALLING SEQUENCE:
+ [[ImageLink(attachment|URL,[WikiName|URL],[width=width,[height=heigt]])]]
+
+ INPUTS:
+ attachment:image name of attachment or the URL to an image
+
+ OPTIONAL INPUTS:
+ WikiName: the page to set the link to or the URL to link to
+
+
+ KEYWORD PARAMETERS:
+ width: width of the embedded image
+ height: height of the embedded image
+
+ EXAMPLE:
+ [[ImageLink(plot.png,FrontPage,width=20,height=20)]]
+ [[ImageLink(plot.png,FrontPage,height=20)]]
+ [[ImageLink(plot.png,FrontPage)]]
+ [[ImageLink(plot.png,width=20,height=20)]]
+ [[ImageLink(plot.png,width=20)]]
+ [[ImageLink(plot.png)]]
+ [[ImageLink(http://localhost/wiki/modern/img/to_slide.png,http://localhost/StartSeite,width=50)]]
+ [[ImageLink(http://localhost/wiki/modern/img/to_slide.png,FrontPage,width=50)]]
+ [[ImageLink(plot.png,http://localhost/StartSeite,width=50)]]
+ [[ImageLink(http://localhost/wiki/modern/img/to_slide.png)]]
+ [[ImageLink(http://localhost/wiki/modern/img/to_slide.png,alt=whateveryouwant)]]
+
+ PROCEDURE:
+ This routine requires attachment enabled. If the attachment isn't downloaded at all
+ the attachment line is shown.
+ If you give only one image size argument e.g. width only the other one is calculated
+
+ It must be in "MoinMoin/macro"
+
+ Please remove the version number from the file name!
+
+ From JeffKunce ImageLink.py I have copied _is_URL to this routine. I have no better idea too.
+
+ HISTORY:
+ The first published version on MoinMoin I know of ImageLink was written by JeffKunce in 2001.
+
+ MODIFICATION HISTORY:
+ @copyright: 2004 by Reimar Bauer (R.Bauer@fz-juelich.de)
+ @license: GNU GPL, see COPYING for details.
+
+ Marcin Zalewski:
+ Some things that were causing problems on my wiki are changed
+ (wikiutil.link_tag and macro.formatter.pagelink implemented)
+
+ Marcin Zalewski:
+ Added title attribute to the created link. One could generalize that to
+ add arbitrary attributes.
+
+ One could also add class attributes to and/or
+
elements. I do not see the need for such modifications. If however this is
+ to be done in the future one would need to add 'html_class' key to the kw dictionary
+ with a corresponding value to add class to
element. To add class to element
+ one needs to add 'css_class' key with a corresponding value to the dictionary passed to
+ pagelink call.
+ Reimar Bauer:
+ 2004-12-23 Adopted to MoinMoin Version 1.3.1-1
+ 2004-12-23 SYNTAX CHANGE Version 1.3.1-2
+ width and height and probably other keywords must be called as keywords (e.g. height=20)
+ 2004-12-31 Version 1.3.1-3 code clean up
+ 2005-01-16 Bug fixed in the errorhandler found and patch code from Malte Helmert
+ 2005-03-05 Version 1.3.3-5 Bug fixed found by cypress
+ ''If I put [[ImageLink(moinmoin.png)]] it bombs''
+ 2005-03-28 Version 1.3.3-6 feature request added by CDPark:
+ ''Can we use an external image? And an external target? ''
+ 2005-04-16 Version 1.3.3-7 no default alt tag definition requested by CDPark and AlexanderSchremmer
+ Chong-Dae Park:
+ 2005-04-17 Version 1.3.3-8 code refactored
+ IMG with no alt tag is not recommended in the HTML standard.
+ It keeps user specified alt tag. If it is not, it tries to use WikiName or image name instead.
+ Reimar Bauer:
+ 2005-04-21 Version 1.3.3-9 bug fixed
+ When the image does not exist yet, it gives you a "Upload Image" link, this link does not
+ work. I suspect that this only is a problem on sub-pages, caused by incorrect escaping of
+ "/". -- CraigJohnson
+
+
+"""
+
+from MoinMoin.action import AttachFile
+from MoinMoin import wikiutil, config
+import os,string
+
+def _is_URL(aString):
+ '''answer true if aString is a URL.
+ The method used here is pretty dumb. Improvements are welcome.
+ jjk 03/28/01'''
+ return string.find(aString, '://')>0
+
+
+def execute(macro, text):
+
+ kw ={} # create a dictionary for the formatter.image call
+
+ if text:
+ args=text.split(',')
+ else:
+ args=[]
+
+ number_args=len(args)
+ count=0
+ for a in args :
+ if (a.find('=') > -1):
+ count=count+1
+ key=a.split('=')
+ kw[str(key[0])]=wikiutil.escape(string.join(key[1],''), quote=1)
+
+ number_args=number_args-count
+
+ if (number_args < 1):
+ msg='Not enough arguments to ImageLink macro! Try [[ImageLink(attachment,[WikiName],[width=width,[height=heigt]])]]'
+ return macro.formatter.sysmsg(1)+macro.formatter.text(msg)+ macro.formatter.sysmsg(0)
+
+
+ attname=wikiutil.taintfilename(macro.formatter.text(args[0]))
+ if (number_args >= 2) :
+ wikiname=args[1]
+ current_pagename=macro.formatter.page.page_name
+
+
+ if _is_URL(args[0]):
+ kw['src']=args[0]
+ else:
+ kw['src']=AttachFile.getAttachUrl(current_pagename,attname,macro.request)
+ attachment_path = os.path.join(AttachFile.getAttachDir(macro.request,current_pagename), attname)
+
+ if not os.path.exists(attachment_path):
+
+ import urllib
+ linktext = macro.request.getText('Upload new attachment "%(filename)s"'%{
+ "filename":attname})
+
+ return wikiutil.link_tag(macro.request,
+ "%(pagename)s?action=AttachFile&rename=%(newname)s" % {
+ "pagename":current_pagename,
+ "newname": attname},linktext)
+
+
+
+ if not kw.has_key('alt'):
+ if (number_args == 1) or _is_URL(args[1]):
+ if _is_URL(args[0]):
+ # Get image name http://here.com/dir/image.gif -> image.gif
+ kw['alt'] = wikiutil.taintfilename(macro.formatter.text(args[0].split('/')[-1]))
+ kw['alt'] = args[0].split('/')[-1]
+ else:
+ kw['alt'] = attname
+ else:
+ kw['alt'] = wikiname
+
+ if (number_args == 1):
+ image_link=macro.formatter.image(**kw)
+ return macro.formatter.url(1,kw['src'] )+image_link +macro.formatter.url(0)
+
+ if (number_args == 2 ):
+ image_link=macro.formatter.image(**kw)
+ if _is_URL(args[1]):
+ return macro.formatter.url(1,args[1] )+image_link+macro.formatter.url(0)
+ else:
+ return macro.formatter.pagelink(1,wikiname)+image_link+macro.formatter.url(0)
+
diff --git a/wiki-lenny/local/macro/InfosBornes.py b/wiki-lenny/local/macro/InfosBornes.py
new file mode 100755
index 00000000..26dad9f2
--- /dev/null
+++ b/wiki-lenny/local/macro/InfosBornes.py
@@ -0,0 +1,89 @@
+#! /usr/bin/env python
+# -*- encoding: iso-8859-1 -*-
+
+# 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(True, {'tablealign': 'center'})
+
+ code += f.table_row(True, {'rowbgcolor': '#FFFFA0'})
+ for nom_col in (u"Nom", u"Hotspot", u"État", u"Localisation", u"Clients",
+ u"MAC", u"Canal", u"Uptime", u"°E", u"°N"):
+ code += f.table_cell(True)
+ code += f.strong(True)
+ code += f.text(nom_col)
+ code += f.strong(False)
+ code += f.table_cell(False)
+ code += f.table_row(False)
+
+
+ bornes.childNodes.sort(lambda x, y: cmp(x.getAttribute(u"nom"),
+ y.getAttribute(u"nom")))
+
+ dico = {u"hotspot": {u"1": f.smiley('(./)'), u"0": f.text(u"")},
+ u"up": {u"1": f.smiley(u"(!)"), u"0": f.smiley(u"{X}")}}
+
+ 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)
+
+
+ for nom_attribut in (u"hotspot", u"up"):
+ code += f.table_cell(1)
+ code += dico[nom_attribut][b.getAttribute(nom_attribut)]
+ code += f.table_cell(0)
+
+ for tag in [u'description', u"clients",u"mac",u"canal"]:
+ 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)
+
+ code += f.table_cell(1)
+ if (b.getElementsByTagName(u"uptime")!=[]):
+ code += f.text("%.2f" % float(b.getElementsByTagName(u"uptime")[0].firstChild.data)+" j")
+ 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
diff --git a/wiki-lenny/local/macro/MonitStatus.py b/wiki-lenny/local/macro/MonitStatus.py
new file mode 100644
index 00000000..965cc61f
--- /dev/null
+++ b/wiki-lenny/local/macro/MonitStatus.py
@@ -0,0 +1,275 @@
+# -*- coding: iso-8859-1 -*-
+
+import os, sys, sre, commands, time
+
+"""
+Permet d'intégrer au wiki les résultats de Monit.
+
+La macro wiki est :
+ [[MonitStatus(hotes=host,categories=[All|Process|File],services=[All|Off|On])]]
+
+Exemple :
+ [[MonitStatus(All|Off|service@host)
+"""
+
+statusfolder = '/usr/scripts/monit/status'
+
+def NotRunningHosts() :
+ """
+ Retourne la liste des hotes ou Monit ne tourne pas ou que
+ le fichier de status est trop vieux
+ """
+ hosts = []
+ for host in os.listdir(statusfolder) :
+ if os.path.getmtime('/usr/scripts/monit/status/%s' % host) < time.time() - 240 :
+ hosts.append(host)
+ return hosts
+
+def HostStatus (host) :
+ """
+ Retourne un dictionnaire représentation de l'état des services de
+ la machine.
+ """
+
+ status = {}
+
+ f = open('%s/%s' % (statusfolder,host) )
+
+ # c'est un hote sous Debian
+ ###########################
+
+ # s est le service qu'on est en trainde parser
+ s = None
+ for line in f.readlines()[2:] :
+ line = line.strip()
+ if not line :
+ # ligne vide, on passe au service suivant
+ s = None
+ elif not s :
+ # création d'un nouveau service
+ s = line.split(' ')[1][1:-1]
+ t = line.split(' ')[0]
+ # ajout du type s'il n'est pas dedans
+ if not status.has_key(t) :
+ status[t] = {}
+ status[t][s] = {}
+ else :
+ # on ajoute les données
+ status[t][s][line[:34].strip()] = line[34:].strip()
+
+ # on supprime les données system
+ try :
+ status.pop('System')
+ except :
+ pass
+
+ return status
+
+def AllStatus () :
+ """
+ Retourne la configuration de toutes les machines
+ """
+ status = {}
+ for host in os.listdir(statusfolder) :
+ status[host] = HostStatus(host)
+ return status
+
+def AllStatusOff () :
+ """
+ Retourne status avec juste les services off
+ """
+
+ status = AllStatus()
+
+ for h in status.keys() :
+
+ # si c'est un host qui est down, on le laisse tel quel pour éviter qu'il le supprime
+ if h in NotRunningHosts() :
+ continue
+
+ # on supprime les types
+ for t in status[h].keys() :
+
+ for s in status[h][t].keys() :
+
+ # on supprime un status s'il est Up
+ if status[h][t][s]['status'] in ['running','accessible'] :
+ status[h][t].pop(s)
+
+ # reste-t-il des services dans le groupe
+ if not status[h][t] :
+ status[h].pop(t)
+
+ # reste-t-il des groupes dans l'hote
+ if not status[h] :
+ status.pop(h)
+
+ return status
+
+def FormatService(Type, Service, Data, f) :
+ """
+ Retourne le code HTML d'un sercice
+ Type : type de service
+ Service : Nom du service
+ Data : dictionnaire contenant toutes les données Data[info]
+ f : formatter
+ """
+
+ result = ''
+ result += f.table_row(1)
+ result += f.table_cell(1,{'style':'background-color:silver'})
+ if Type == 'Device' :
+ Service = Service[2:]
+ elif Type == 'File' :
+ Service = Service[4:]
+ result += f.strong(1)
+ result += f.text(Service)
+ result += f.strong(0)
+ result += f.table_cell(0)
+ if Data['status'] in ['running','accessible'] :
+ result += f.table_cell(1,{'style':'background-color:lime'})
+ else :
+ result += f.table_cell(1,{'style':'background-color:red'})
+ result += f.text(Data['status'])
+ result += f.table_cell(0)
+ result += f.table_row(0)
+ return result
+
+def FormatType(Type, Data, f) :
+ """
+ Retourne le code HTML d'une liste de services
+ Host : nom de l'hote
+ Data : dictionnaire contenant toutes les données Data[service][info]
+ f : formatter
+ """
+
+ result = ''
+
+ # titre
+ result += f.heading(1,3)
+ result += f.text(Type)
+ result += f.heading(0,3)
+
+ # les services
+ result += f.table(1)
+ for s in Data.keys() :
+ result += FormatService(Type,s,Data[s],f)
+ result += f.table(0)
+
+ return result
+
+def FormatHost (Host, Data, f) :
+ """
+ Retourne le code HTML d'un hôte
+ Host : nom de l'hote
+ Data : dictionnaire contenant toutes les données Data[type][service][info]
+ f : formatter
+ """
+
+ result = ''
+
+ # titre
+ result += f.heading(1,2)
+ result += f.text(Host)[0].upper() + f.text(Host)[1:]
+ result += f.heading(0,2)
+
+ # si monit ne tourne pas
+ if Host in NotRunningHosts() :
+ return result + Cellule('Monit ne semble pas tourner sur %s' % Host,'yellow',f)
+
+ result += f.table(1)
+ result += f.table_row(1)
+ for t in Data.keys() :
+ result += f.table_cell(1,{'valign':'top'})
+ result += FormatType(t,Data[t],f)
+ result += f.table_cell(0)
+
+ result += f.table_row(0)
+ result += f.table(0)
+
+ return result
+
+def FormatHosts(Data, f) :
+ """
+ Retourne le code HTML de tous les hotes fournis
+ Data : dictionnaire contenant toutes les données Data[hote][type][service][info]
+ f : formatter
+ """
+
+ result = ''
+
+ for h in Data.keys() :
+ result += FormatHost(h,Data[h],f)
+
+ return result
+
+def Cellule(texte, couleur, f) :
+ """
+ Retourne le code HTML d'une cellule formattée aver le formatter f
+ """
+ code = f.table(1)
+ code += f.table_row(1)
+ code += f.table_cell(1,{'style':'background-color:%s' % couleur })
+ code += f.text(texte)
+ code += f.table_cell(0)
+ code += f.table_row(0)
+ code += f.table(0)
+ return code
+
+def execute(macro, filtre) :
+ """
+ Corps principal de la macro
+ """
+ f = macro.formatter
+
+ # on met en forme le filtre
+ if not filtre :
+ filtre = 'all'
+ else :
+ filtre = filtre.lower()
+
+ if filtre == 'off' :
+ # tous les services off
+ status = AllStatusOff()
+ if status :
+ return FormatHosts(status, f)
+ else :
+ # aucun service off, on affiche OK
+ return Cellule(u'Tous les services semblent opérationnels.','lime',f)
+
+ elif filtre == 'all' :
+ # tous les services
+ status = AllStatus()
+ return FormatHosts(status, f)
+
+ elif '@' in filtre :
+ # affichage d'un service simple
+
+ host = filtre.split('@')[1]
+ service = filtre.split('@')[0]
+ status = HostStatus(host)
+
+ # recherche du service dans la config
+ s = {}
+ for t in status.keys() :
+ if service in status[t].keys() :
+ s = status[t][service]
+
+ if not s :
+ # service non trouvé
+ code = f.table_cell(0)
+ code += f.table_cell(1,{'style':'background-color:yellow'})
+ code += f.text(u'Service introuvable')
+ return code
+
+ # création de la chaine de retour
+ code = f.table_cell(0)
+ if s['status'] in ['running','accessible'] :
+ code += f.table_cell(1,{'style':'background-color:lime'})
+ else :
+ code += f.table_cell(1,{'style':'background-color:red'})
+ code += f.text(s['status'])
+ return code
+
+ else :
+ return Cellule('Erreur de filtre','yellow',f)
diff --git a/wiki-lenny/local/macro/ProgressBar.py b/wiki-lenny/local/macro/ProgressBar.py
new file mode 100644
index 00000000..5f39cba2
--- /dev/null
+++ b/wiki-lenny/local/macro/ProgressBar.py
@@ -0,0 +1,225 @@
+"""
+MoinMoin - ProgressBar Macro
+Generates a progress bar (in the form of a table)
+
+@copyright: Pascal Bauermeister
%s