Skip to content

Commit

Permalink
bug fixes in FTP and Azure Blob storage providers
Browse files Browse the repository at this point in the history
  • Loading branch information
SharonBrizinov committed Jan 27, 2021
1 parent 3fcc2bd commit 1aff676
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/providers/azure_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def check(self):
if not find_executable("azcopy") and not shutil.which("azcopy"):
show_message_box("azcopy not found. Please make sure you have placed azcopy somewhere in the PATH. https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10")
return False
container = urlparse(self.url.lower()).path
if not container or container == "/":
show_message_box("Please provide container name as well. https://BLOBNAME.blob.core.windows.net/CONTAINER")
return False
return True

def get_download_url(self, relative_path):
Expand All @@ -41,7 +45,7 @@ def _parse_line(self, line):
if line_parsed:
file_path, size = line_parsed[0]
# TODO: Currently there is no date in azcopy output, so we are faking one
return "1970-01-01 00:00:00 {:>13} {}".format(size, file_path) + os.linsep
return "1970-01-01 00:00:00 {:>13} {}".format(size, file_path) + os.linesep
return None

def yield_dirlist(self):
Expand Down
6 changes: 3 additions & 3 deletions src/providers/ftp_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ def is_provider(url):
def check(self):
try:
self.ftp = FTP(self.hostname(), FTP_USER_DEFAULT, FTP_PASS_DEFAULT)
return self.ftp.pwd() == "/"
if self.ftp.pwd():
return True
return False
except Exception as e:
show_message_box(self.get_default_error_message())
return False
Expand All @@ -185,8 +187,6 @@ def get_download_url(self, relative_path):
def yield_dirlist(self):
if not self.ftp:
self.ftp = FTP(self.hostname(), FTP_USER_DEFAULT, FTP_PASS_DEFAULT)
if not self.ftp.pwd() == "/":
raise Exception(self.get_default_error_message())

for dirlist_line in yield_fetch_dir(self.ftp, self.url_path()):
# Stop
Expand Down

0 comments on commit 1aff676

Please sign in to comment.