Bonjour;
J'essaye de lancer plusieurs thred ds une boucle, mais il ne se passe rien ?
Le code :
# script run
import sys, glob, socket, thread, os, os.path, string
from ftplib import FTP
dir_result = '../RES'
EXTFIC = ".res"
dir_tmp = '../tmp'
def init(script_name):
dir_part, file_part = os.path.split(script_name)
fichier= dir_result+'/'+file_part+EXTFIC
if not os.path.exists(dir_result):
os.mkdir(dir_result)
else:
if os.path.isfile(fichier):
os.system('del "%s"' % fichier)
return fichier
def Telecharger(dir):
listefile = []
ftp = FTP('stldev'
ftp.connect('stldev', '21'
ftp.login('proftpd', 'password'
remote_dir = string.replace(os.path.join('terminaux', 'M16-0600-2704' ), os.sep, '/' )
ftp.cwd(remote_dir)
ftp.pwd()
ftp.dir()
listefile = ftp.nlst("." )
for file in listefile:
file_cible = open(os.path.join(os.path.dirname(dir), file), 'w+'
ftp.retrbinary("RETR "+ file, file_cible.write,1024)
file_cible.close()
fichier = init(sys.argv[0])
fsock1 = open(fichier , 'w+'
fsock2 = open(fichier, 'a+'
sys.stdout = fsock1
sys.stderr = fsock2
for i in range (10):
dir_tmp = '../tmp' + `i`
if not os.path.exists(dir_tmp):
os.mkdir(dir_tmp)
thread.start_new_thread(Telecharger, (dir_tmp,))
saveout = sys.stdout
fsock1.close()
fsock2.close()
A+;