Skip to content

Commit

Permalink
Modifications to also work with NCBI FTP
Browse files Browse the repository at this point in the history
  • Loading branch information
mschor committed Feb 28, 2019
1 parent 7ce225e commit e7618aa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _get_ftp_connection(self, host):

if host not in self.connections:
ftp = FTP(host)
ftp.login('portal_client')
ftp.login()
self.connections[host] = ftp

conn = self.connections[host]
Expand All @@ -88,7 +88,7 @@ def _get_url_obj(self, url, current_byte):
ftp = self._get_ftp_connection(parsed['host'])

# make sure there's something there
if list(ftp.mlsd(parsed['file_path'])):
if list(ftp.nlst(parsed['file_path'])):
file_str = "RETR {0}".format(parsed['file_path'])

def get_data(callback, blocksize, start_pos):
Expand All @@ -107,8 +107,10 @@ def _get_file_size(self, url):

parsed = self._parse_ftp_url(url)
ftp = self._get_ftp_connection(parsed["host"])

return ftp.size(parsed["file_path"])
ftp.sendcmd("TYPE i")
file_size = ftp.size(parsed["file_path"])
self.logger.debug("size is: " + str(file_size))
return file_size

# Function to retrieve a particular set of bytes from the file.
# Arguments:
Expand Down

0 comments on commit e7618aa

Please sign in to comment.