Hi all,
I am trying to get some files from an ftp site by ftplib module and I wrote the below script. However I have a problem. With my script, I login to ftp.genome.jp site. then, I am changing the directory to pub/kegg/genomes/afm and I am downloading "a.fumigatus.pep" file. However, what I want is to connect pub/kegg/genomes directory and in this directory there are 3 letters name files e.g. 'afm' and in each of these 3 letters files there is a file with the extension of '.pep' like a.fumigatus.pep. I want to get these '.pep' files from the 3 letter named files. If you help me I will be very glad. Thanks you in advance.
Regards,
Alper
from ftplib import FTP
def handleDownload( block):
file.write(block)
print ".",
ftp = FTP('ftp.genome. jp')
print ftp.login()
directory = 'pub/kegg/genomes/ afm'
print 'Changing to ' + directory
ftp.cwd(directory)
ftp.retrlines( 'LIST')
filename = 'a.fumigatus. pep'
print 'Opening local file ' + filename
file = open(filename, 'wb')
print 'Getting ' + filename
ftp.retrbinary( 'RETR ' + filename, handleDownload)
print 'Closing file ' + filename
file.close()
print 'Closing FTP connection'
print ftp.close()
I am trying to get some files from an ftp site by ftplib module and I wrote the below script. However I have a problem. With my script, I login to ftp.genome.jp site. then, I am changing the directory to pub/kegg/genomes/afm and I am downloading "a.fumigatus.pep" file. However, what I want is to connect pub/kegg/genomes directory and in this directory there are 3 letters name files e.g. 'afm' and in each of these 3 letters files there is a file with the extension of '.pep' like a.fumigatus.pep. I want to get these '.pep' files from the 3 letter named files. If you help me I will be very glad. Thanks you in advance.
Regards,
Alper
from ftplib import FTP
def handleDownload( block):
file.write(block)
print ".",
ftp = FTP('ftp.genome. jp')
print ftp.login()
directory = 'pub/kegg/genomes/ afm'
print 'Changing to ' + directory
ftp.cwd(directory)
ftp.retrlines( 'LIST')
filename = 'a.fumigatus. pep'
print 'Opening local file ' + filename
file = open(filename, 'wb')
print 'Getting ' + filename
ftp.retrbinary( 'RETR ' + filename, handleDownload)
print 'Closing file ' + filename
file.close()
print 'Closing FTP connection'
print ftp.close()
-- http://mail.python.org/mailman/listinfo/python-list