From fd4d4a7f9a3a73b934a7f87910c39a33f9021363 Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Sun, 24 Jun 2012 00:57:19 +0200 Subject: [PATCH] [whokfet] patch de whokfet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ignore-this: 608c136f00a8783eadbcc8fde6c3d7d6 Parce qu'en lisant un xml (regénéré toutes les 5min), c'est plus rapide. Et plus besoin de clef-wifi-kfet darcs-hash:20120623225719-28565-61e146d67ac03564540d16e2f07b403dcff721bd.gz --- gestion/tools/whokfet.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/gestion/tools/whokfet.py b/gestion/tools/whokfet.py index eab62191..3f002a8f 100755 --- a/gestion/tools/whokfet.py +++ b/gestion/tools/whokfet.py @@ -11,22 +11,15 @@ from affich_tools import coul, cprint from whos import aff from socket import gethostname from os import system -from subprocess import Popen, PIPE - +import xml.dom.minidom def get_wifi_connected_client(): - x=Popen(["ssh","-T", "-i" , "/usr/scripts/gestion/clef-wifi-kfet","-l","root" ,"-x", "-o", "BatchMode=yes", "-o", - "ConnectTimeout=5", "-o", "StrictHostKeyChecking=no","valhalla.wifi", "/usr/crans/list_clients.sh"], stdout=PIPE) - clients=x.communicate()[0].split("\n") - macs=[] - for client in clients: - try: - macs.append(client.split(" ")[1]) - except IndexError: pass - return macs + f = open('/usr/scripts/var/wifi_xml/valhalla.xml','r') + doc = xml.dom.minidom.parse(f) + f.close() + return [ mac.firstChild.nodeValue for mac in doc.getElementsByTagName('mac') ] def liste_kfet(): - sw = hpswitch('batb-0') db = crans_ldap() try: