Note that there are some explanatory texts on larger screens.

plurals
  1. POPython ftplib EOFerror
    primarykey
    data
    text
    <p>I have a script that connects to server and makes a local copy of the whole directory. EOFerror occurs after exactly 50 files of any choice have been downloaded.</p> <p><strong>Can anyone please tell me, what is wrong with the script?</strong></p> <p>ERROR:</p> <pre><code>Traceback (most recent call last): File "ftp.py", line 37, in &lt;module&gt; 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 </code></pre> <p>SCRIPT:</p> <pre><code>#!/usr/bin/python import ftplib import sys import os import datetime def ftp_walk(ftp): dirs = ftp.nlst() for item in (path for 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: with open(currdir+"/"+item, 'wb') as 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() </code></pre> <p>Edit: After manual update of ftplib for python 2.7:</p> <pre><code>Traceback (most recent call last): File "ftp.py", line 29, in &lt;module&gt; 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 an unexpected keyword argument 'encoding' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload