[gestion/] Kill popen, subprocess ftw

On diminue le nombre de DeprecationWarnings ...

darcs-hash:20110307225857-ddb99-74a1452ba6f828f102e8803de1307e8147314887.gz
This commit is contained in:
Michel Blockelet 2011-03-07 23:58:57 +01:00
parent ecb6e01317
commit e9242a36af
3 changed files with 9 additions and 8 deletions

View file

@ -7,7 +7,7 @@ Copyright (C) Frédéric Pauget
Licence : GPLv2 Licence : GPLv2
""" """
import sys, re, os, tempfile import sys, re, os, tempfile, subprocess
# Détermination de l'encodage # Détermination de l'encodage
encoding = None encoding = None
@ -25,9 +25,9 @@ if encoding == "ANSI_X3.4-1968":
encoding = "ISO-8859-15" encoding = "ISO-8859-15"
if 'TERM' in os.environ and os.environ['TERM'] != 'unknown': if 'TERM' in os.environ and os.environ['TERM'] != 'unknown':
el = os.popen('tput cr ; tput el').read() el = subprocess.Popen('tput cr ; tput el', shell=True, stdout=subprocess.PIPE).stdout.read()
else: else:
el = os.popen('tput -Tvt100 cr ; tput -Tvt100 el').read() el = subprocess.Popen('tput -Tvt100 cr ; tput -Tvt100 el', shell=True, stdout=subprocess.PIPE).stdout.read()
try: try:
stdout_atty = sys.stdout.isatty() stdout_atty = sys.stdout.isatty()

View file

@ -10,7 +10,6 @@ Donne la classe switch qui permet d'effectuer les opérations
Frédéric PAUGET Frédéric PAUGET
""" """
from time import sleep from time import sleep
from popen2 import popen3
from sys import stderr, path from sys import stderr, path
from commands import getstatusoutput from commands import getstatusoutput
from annuaires_pg import chbre_prises, all_switchs from annuaires_pg import chbre_prises, all_switchs

View file

@ -56,7 +56,7 @@ from ldap_crans import MachineCrans, MachineWifi, BorneWifi
from ldap_crans import Adherent from ldap_crans import Adherent
from affich_tools import * from affich_tools import *
import user_tests import user_tests
import popen2, commands import subprocess, commands
limit_aff_details = 1 limit_aff_details = 1
limit_aff_machines = 15 limit_aff_machines = 15
@ -939,9 +939,11 @@ def borne_clients_canal(borne) :
for clef in ["/etc/wifi/ssh/wifi","/usr/scripts/gestion/clef-wifi"]: for clef in ["/etc/wifi/ssh/wifi","/usr/scripts/gestion/clef-wifi"]:
if os.path.isfile(clef) and user_tests.isadm(): if os.path.isfile(clef) and user_tests.isadm():
try: try:
wl = popen2.Popen3("ssh -o StrictHostKeyChecking=no -i %s root@%s 'cat /tmp/auth-mac.dump ; echo -n \"CANAL \" ; /usr/sbin/nvram get wl0_channel' 2> /dev/null" % (clef, borne)) wl = subprocess.Popen("ssh -o StrictHostKeyChecking=no -i %s root@%s 'cat /tmp/auth-mac.dump ; echo -n \"CANAL \" ; /usr/sbin/nvram get wl0_channel'" % (clef, borne), shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
wl.tochild.close() wl.stdin.close()
for line in wl.fromchild.readlines(): for line in wl.stdout.readlines():
print 'coucou'
print line
# Chaque ligne est de la forme # Chaque ligne est de la forme
# 00:11:22:33:44:55 -20 # 00:11:22:33:44:55 -20
line = line.strip().split() line = line.strip().split()