From 67ae8a7fcb4b9ff7dab389d90d75f66f702a2ce5 Mon Sep 17 00:00:00 2001 From: Dakota Howard <58985143+dthoward96@users.noreply.github.com> Date: Fri, 23 Feb 2024 09:57:13 -0500 Subject: [PATCH] FTP folder bug fix submit.py Some FTP accounts have the folder structure /submit/Production/ instead of /Production/. This fix automatically corrects for this difference in folder structure. --- submit.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/submit.py b/submit.py index d2cfcc4..645c01e 100644 --- a/submit.py +++ b/submit.py @@ -48,9 +48,20 @@ def submit_ncbi(database, submission_name, submission_dir, config_dict, submissi print("If this is not a '" + submission_type + "' submission, interrupts submission immediately.", file=sys.stdout) print("\n"+"Connecting to NCBI FTP Server", file=sys.stdout) print("Submission name: " + submission_name, file=sys.stdout) - # CD to to test/production folder + # Check FTP folder structure either /submit/Production/ or /Production/ + if submission_type not in ftp.nlst(): + # Check if submit folder exists + if "submit" in ftp.nlst(): + ftp.cwd("submit") + # If submit folder exists check if Production/Test folder exists + if submission_type not in ftp.nlst(): + print("Error: Cannot find submission folder on NCBI FTP site.", file=sys.stderr) + sys.exit(1) + else: + print("Error: Cannot find submission folder on NCBI FTP site.", file=sys.stderr) + sys.exit(1) ftp.cwd(submission_type) - # Create submission directory if it does not exist + # Create submission name directory if it does not exist if ncbi_submission_name not in ftp.nlst(): ftp.mkd(ncbi_submission_name) # CD to submission folder