[ftputil] How to correctlry close a ftp connection
Yvan Strahm
yvan.strahm at gmail.com
Fri Dec 12 13:40:02 CET 2008
Hello,
I get this error:
Traceback (most recent call last):
File "./map_taxo.py", line 186, in ?
Download_me(ftp,ftp_dir,file,target)
File "./map_taxo.py", line 95, in Download_me
host=ftputil.FTPHost(ftp,user,password)
File "/usr/lib/python2.4/site-packages/ftputil/ftputil.py", line 136, in
__init__
self._session = self._make_session()
File "/usr/lib/python2.4/site-packages/ftputil/ftputil.py", line 174, in
_make_session
return ftp_error._try_with_oserror(factory, *args, **kwargs)
File "/usr/lib/python2.4/site-packages/ftputil/ftp_error.py", line 86, in
_try_with_oserror
raise PermanentError(obj)
ftputil.ftp_error.PermanentError: 530 Sorry, the maximum number clients (32)
from your host are already connected.
Debugging info: ftputil 2.2.3, Python 2.4.3 (linux2)
I have a list of file s to be downloaded and open/close for every items. Is
it the correct way of doing it?
def Download_me(ftp,ftp_dir,file,target):
user = 'anonymous'
password = 'anonymous'
try:
print "CONNECTING TO "+ ftp + ftp_dir+file+"\n"
host=ftputil.FTPHost(ftp,user,password)
host.chdir(ftp_dir+file)
names=host.listdir(host.curdir)
for name in names:
if host.path.isfile(name):
p="pep"
m_pep=re.search(p,name)
if m_pep:
returned=name
host.download_if_newer(name,target,'b')
host.close()
except:
print "could not be dowloaded try KAAS"
ftp='ftp.genome.jp'
ftp_dir='/pub/kegg/genes/organisms_kaas/'
print "CONNECTING TO "+ ftp + ftp_dir+file+"\n"
host=ftputil.FTPHost(ftp,user,password)
host.chdir(ftp_dir+file)
names=host.listdir(host.curdir)
for name in names:
if host.path.isfile(name):
p="pep"
m_pep=re.search(p,name)
if m_pep:
returned=name
host.download_if_newer(name,target,'b')
host.close()
Thanks for your help.
yvan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/ftputil/attachments/20081212/f9a432df/attachment-0001.htm
More information about the ftputil
mailing list