Skip to content

Commit

Permalink
ENH: add useful error message when can't change directories on ftp site
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinHuttley committed Feb 4, 2025
1 parent 7aba30c commit c44e94a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/ensembl_tui/_ftp_download.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pathlib
import typing
from collections.abc import Callable
from ftplib import FTP
from ftplib import FTP, error_perm

from rich.progress import Progress, track
from unsync import unsync
Expand All @@ -23,10 +23,25 @@ def listdir(
"""returns directory listing"""
pattern = pattern or (lambda x: True)
ftp = configured_ftp(host=host)
ftp.cwd(path)
try:
ftp.cwd(path)
except error_perm:
msg = "\n".join(
[
"",
f"Skipping {path}",
"Could not change into directory on FTP site.",
"This can be because of Ensembl naming inconsistencies.",
"Check names are consistent between genomes and homology.",
],
)
eti_util.print_colour(msg, "red")
return

for fn in ftp.nlst():
if pattern(fn):
yield f"{path}/{fn}"

ftp.close()


Expand Down

0 comments on commit c44e94a

Please sign in to comment.