From d1480862b03d1bd2e50e0ce3e2d4b3ce85e69c89 Mon Sep 17 00:00:00 2001 From: Antoine Durand-Gasselin Date: Tue, 25 May 2010 01:06:46 +0200 Subject: [PATCH] =?UTF-8?q?[wifi/status.py]=20on=20peut=20pr=C3=A9ciser=20?= =?UTF-8?q?le=20fichier=20d'output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit darcs-hash:20100524230646-bd074-f76fc5d753393c5fe4999ce2617a49188a98cf12.gz --- wifi/status.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/wifi/status.py b/wifi/status.py index 832c5a75..97d1472e 100644 --- a/wifi/status.py +++ b/wifi/status.py @@ -3,12 +3,16 @@ # Génération d'un fichier XML indiquant le status des bornes -import sys -import os -import time +import sys, os, time, optparse sys.path.append("/usr/scripts/gestion") sys.path.append("/usr/scripts/wifi") +### parsing +parser = optparse.OptionParser(usage="usage: %prog [-o FILE]") +parser.add_option('-o', '--output', help=u"outputs to FILE", + metavar='FILE', dest="filename") +(options, args) = parser.parse_args() + from bornes import bornes_canal, bornes_clients, bornes_uptime from ldap_crans import crans_ldap @@ -88,4 +92,9 @@ for b in bornes: xml_bornes.appendChild(xml_borne) -print (status.toxml().encode("UTF-8")) +if options.filename: + f = open(options.filename, 'w') + f.write(status.toxml().encode("UTF-8")) + f.close() +else: + print (status.toxml().encode("UTF-8"))