ftp - Python ftplib EOFerror -


i have script connects server , makes local copy of whole directory. eoferror occurs after 50 files of choice have been downloaded.

can please tell me, wrong script?

error:

traceback (most recent call last):   file "ftp.py", line 37, in <module>     ftp_walk(ftp)   file "ftp.py", line 17, in ftp_walk     currdir = ftp.pwd()[1:]   file "/usr/lib/python2.7/ftplib.py", line 574, in pwd     resp = self.sendcmd('pwd')   file "/usr/lib/python2.7/ftplib.py", line 244, in sendcmd     return self.getresp()   file "/usr/lib/python2.7/ftplib.py", line 210, in getresp     resp = self.getmultiline()   file "/usr/lib/python2.7/ftplib.py", line 196, in getmultiline     line = self.getline()   file "/usr/lib/python2.7/ftplib.py", line 186, in getline     if not line: raise eoferror eoferror 

script:

#!/usr/bin/python  import ftplib import sys import os import datetime  def ftp_walk(ftp):         dirs = ftp.nlst()     item in (path path in dirs if path not in ('.', '..')):         try:             ftp.cwd(item)             print datetime.datetime.now().strftime("%y-%m-%d %h:%m")+' dir: ', ftp.pwd()             ftp_walk(ftp)             ftp.cwd('..')         except exception, e:             currdir = ftp.pwd()[1:]             if not os.path.exists(currdir): os.makedirs(currdir)             try:                 open(currdir+"/"+item, 'wb') f:                      def callback(data):                         f.write(data)                      ftp.retrbinary('retr %s' % item, callback)                     f.close()                     print datetime.datetime.now().strftime("%y-%m-%d %h:%m")+' retr: '+ currdir+"/"+item             except exception, e:                 print e   ftp = ftplib.ftp("hhhhhhhhhhhhhh") ftp.login("aaaaaaaa", "bbbbbbbbbbb") ftp.sendcmd("type i") #binary mode ftp.set_pasv(true) # trying passive mode ftp.cwd("public_html/eeeeeeee/rrrrrrrr/images") ftp_walk(ftp) ftp.quit() 

edit: after manual update of ftplib python 2.7:

traceback (most recent call last):   file "ftp.py", line 29, in <module>     ftp = ftplib.ftp("something.com")   file "/usr/lib/python2.7/ftplib.py", line 114, in __init__     self.connect(host)   file "/usr/lib/python2.7/ftplib.py", line 150, in connect     self.file = self.sock.makefile('r', encoding=self.encoding) typeerror: makefile() got unexpected keyword argument 'encoding' 

i have tried script , works without problems. pulled 233 images server using it. try setting current dir ftp.cwd("./public_html/eeeeeeee/rrrrrrrr/images") , see happens...


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -