Problème changement de répertoire avec ftplib
Bonjour,
Je suis en train décrire un petit client FTP mais malheureusement je suis bloquer sur une boucle :/
Voici l'erreur:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
t.MAJ()
File "C:\Users\Norian\Dropbox\Spangler\Code source\FTP.py", line 68, in MAJ
self.ftp.cwd(dossier + "//")
File "C:\Python27\lib\ftplib.py", line 562, in cwd
return self.voidcmd(cmd)
File "C:\Python27\lib\ftplib.py", line 254, in voidcmd
return self.voidresp()
File "C:\Python27\lib\ftplib.py", line 229, in voidresp
resp = self.getresp()
File "C:\Python27\lib\ftplib.py", line 224, in getresp
raise error_perm, resp
error_perm: 550 CWD failed. "/nono/11031938_1109950805697283_1069068117774435383_n.jpg/14706_10205412006411214_3091834777189694657_n.jpg": directory not found. |
J'ai beau cherché et je ne comprends pas pourquoi je me trouve dans ce repertoire :/
Voici la partie du code qui a un problème:
Code:
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
| def MAJ(self):
ok = 1
boucle = True
os.chdir("Temp//")
try:
self.ftp.cwd(self.pseu + "//")
except:
ok = 0
if ok ==1:
rep = self.ftp.nlst("")
for dossier in rep:
self.ftp.cwd(dossier + "//")
files = self.ftp.nlst("")
while boucle:
try:
os.mkdir(dossier)
print files
for f in files:
print f
if f != "path":
self.ftp.retrbinary('RETR ' + f,open(dossier +"//" +f, 'wb').write)
self.ftp.cwd("path//")
path = self.ftp.nlst("")
os.mkdir(dossier + "//path")
for chemins in path:
self.ftp.retrbinary('RETR ' + chemins,open(dossier +"//path//" + chemins, 'wb').write)
self.ftp.cwd("..//..//")
boucle = False
except WindowsError:
print "erreur"
shutil.rmtree(dossier+"//")
boucle = True |
Quelqu'un pour m'aider ?
Merci d'avance pour votre aide :)