From f62c85bf0e641f708cef982a431c5059c3d8c852 Mon Sep 17 00:00:00 2001 From: maloneytc Date: Tue, 8 Nov 2022 14:57:55 -0500 Subject: [PATCH] Update Download.py Added check on the existence of failed_s3_links_file before it is deleted. --- NDATools/Download.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NDATools/Download.py b/NDATools/Download.py index 4804db3..6fb8e0a 100644 --- a/NDATools/Download.py +++ b/NDATools/Download.py @@ -358,8 +358,9 @@ def download(file_id_to_cred_list): # dont generate a file if there were no failures if not self.package_file_download_errors: - logger.info('No failures detected. Removing file {}'.format(failed_s3_links_file.name)) - os.remove(failed_s3_links_file.name) + if os.path.exists(failed_s3_links_file.name): + logger.info('No failures detected. Removing file {}'.format(failed_s3_links_file.name)) + os.remove(failed_s3_links_file.name) logger.info('') @@ -1058,4 +1059,4 @@ def get_completed_files_in_download(self): with open(download_progress_report_path, newline='') as csvfile: file_reader = csv.DictReader(csvfile) files = [f for f in file_reader if bool(f['exists'])] - return files \ No newline at end of file + return files