From e7618aa74419bb7dfa8af9bbd2a3d265d353de82 Mon Sep 17 00:00:00 2001 From: mschor Date: Thu, 28 Feb 2019 17:09:34 -0500 Subject: [PATCH] Modifications to also work with NCBI FTP --- lib/ftp.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ftp.py b/lib/ftp.py index 5cbb951..c7e8403 100644 --- a/lib/ftp.py +++ b/lib/ftp.py @@ -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] @@ -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): @@ -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: