From 75d94c25a93e02398149f216c5eb97543a9166c3 Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Fri, 10 Feb 2012 13:02:23 +0100 Subject: [PATCH] [wifi/bornes.py] Utilisation de subprocess.Popen darcs-hash:20120210120223-28565-6eda2ef1c67e05f01ae0d325cd0b89d852aaa48a.gz --- wifi/bornes.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wifi/bornes.py b/wifi/bornes.py index eb2176b0..ffc0479f 100755 --- a/wifi/bornes.py +++ b/wifi/bornes.py @@ -11,6 +11,7 @@ La sortie est la sortie de `uname -v` sur chaque borne.""" import sys, os, commands, re, time +from subprocess import Popen, PIPE from optparse import OptionParser LOG = "/var/log/wifi/wifi.log" @@ -37,10 +38,10 @@ def bornes(): def ssh_exec(host, cmd): """Execute une commande en ssh sur une machine et renvoie le résultat""" - (stdin, stdout, stderr) = os.popen3("ssh -T -x -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=no -l root -i /usr/scripts/gestion/clef-wifi %(host)s %(cmd)s" % locals()) - stdin.close() - stderr.close() - return stdout + p = Popen("ssh -T -x -o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=no -l root -i /usr/scripts/gestion/clef-wifi %(host)s %(cmd)s" % locals(), shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + p.stdin.close() + p.stderr.close() + return p.stdout def bornes_canal(): names = bornes()