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"))