I’m trying to upload lots of files using python’s ftplib.
What kind of exception should I catch to be sure the problem is a connection error (so I can re-connect)?
Edit:
I tried all_errors in this scenario:
- Connected to FTP server by
ftpliband paused application (via debugger) before file upload - Closed connection via server
- Resumed Application
With this code:
try:
self.f.cwd(dest)
return self.f.storbinary(('STOR '+n).encode('utf-8'), open(f,'rb'))
except ftplib.all_errors as e:
print e
exception caught but all_errors was empty:
e EOFError:
args tuple: ()
message str:
You can look it up in the documentation: http://docs.python.org/2/library/ftplib.html#ftplib.error_reply
Also don’t forget: http://docs.python.org/2/library/ftplib.html#ftplib.all_errors