Bonjour à tous,

Je viens vers vous pour vous exposez un problème assez étrange!
J'ai codé (enfin.... copié en grosse partie) un petit code en python pour rapatrier tout les fichiers d'un dossier ftp.
Le programme fonctionne super bien sous Debian... mais se bloque sous Windows... Et je ne comprend pas pourquoi!

Voici le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
import ftplib
import os
import time
 
class ftp(ftplib.FTP):
    def __init__(self, adresse='xx.xx.xx.xx', port=21, user='xxxx', password='xxxxxxx'):
        ftplib.FTP.__init__(self, '')
        self.adresse = adresse
        self.port = port
        self.user = user
        self.password = password
    def Reconnect(self):
        try:
            print "connect %s: %s" % (self.adresse, self.port)
            self.connect(self.adresse, self.port) ## Recherche FTP
            self.login(self.user, self.password) ## Connexion
            self.set_pasv(False)
        except:
            print "Erreur de connection: Tentative dans 10 seconde"
            time.sleep(10)
            self.Reconnect()
 
    def Command(self, command, *args):
        try:
            return command(*args)
        except:
            self.Reconnect()
            return command(*args)
 
session = ftp()
lst = []
session.Command(session.retrlines, 'LIST /dossier/', lst.append)
i = 0
for fich in lst:
  i += 1
  if not i in [1,2,3]:
    tab = fich.split()
    session.Command(session.retrbinary, "RETR /dossier/%s"%tab[8] , open('c:/dossier/%s'%tab[8], 'wb').write)
 
session.close()
Merci de votre aide, je suis désespéré!

Edit: J'oubliais... Je suis sous windows XP ou 2003 et j'utilise python 2.5