From 30fad86312938ce5b38676b96ff20cb02ba5e740 Mon Sep 17 00:00:00 2001 From: Jong Date: Mon, 6 Nov 2023 16:13:08 -0600 Subject: [PATCH 1/4] HGI-4481 - added logs --- target_sftp/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target_sftp/__init__.py b/target_sftp/__init__.py index 52d7505..48fa2ce 100644 --- a/target_sftp/__init__.py +++ b/target_sftp/__init__.py @@ -52,9 +52,13 @@ def upload(args): # check if structure exists before changing sftp_client.chdir(dir) #will change if folder already exists except IOError: + logger.info(f"Creating new folder path at {sftp_client.getcwd()}") + try: sftp_client.mkdir(dir) logger.info(f"Creating output path at {sftp_client.getcwd()}") sftp_client.chdir(dir) + except Exception as e: + logger.info(f"Failed to create folder path at {sftp_client.getcwd()}. Folder skipped {dir}. Error message {e}") for root, dirs, files in os.walk(config["input_path"]): @@ -77,7 +81,7 @@ def upload(args): # Save the file logger.info(f"Uploading {file} to {config['path_prefix']} at {sftp_client.getcwd()}") - sftp_client.put(file_path, file) + # sftp_client.put(file_path, file) if prev_cwd is not None: sftp_client.chdir(prev_cwd) From add296c8d0bf85f4e326d2464e774cf570a1276f Mon Sep 17 00:00:00 2001 From: Jong Date: Mon, 6 Nov 2023 16:14:57 -0600 Subject: [PATCH 2/4] HGI-4481 - added logs --- target_sftp/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_sftp/__init__.py b/target_sftp/__init__.py index 48fa2ce..cdfc6ba 100644 --- a/target_sftp/__init__.py +++ b/target_sftp/__init__.py @@ -81,7 +81,7 @@ def upload(args): # Save the file logger.info(f"Uploading {file} to {config['path_prefix']} at {sftp_client.getcwd()}") - # sftp_client.put(file_path, file) + sftp_client.put(file_path, file) if prev_cwd is not None: sftp_client.chdir(prev_cwd) From 643e738ec62c535a523a3c5fda15d71d04832f0b Mon Sep 17 00:00:00 2001 From: Jong Date: Tue, 7 Nov 2023 08:15:53 -0600 Subject: [PATCH 3/4] HGI-4481 - added error --- target_sftp/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/target_sftp/__init__.py b/target_sftp/__init__.py index cdfc6ba..88db0d4 100644 --- a/target_sftp/__init__.py +++ b/target_sftp/__init__.py @@ -59,6 +59,7 @@ def upload(args): sftp_client.chdir(dir) except Exception as e: logger.info(f"Failed to create folder path at {sftp_client.getcwd()}. Folder skipped {dir}. Error message {e}") + raise NotADirectoryError for root, dirs, files in os.walk(config["input_path"]): From 92db579b477a3800aac164b98690fa54149dc197 Mon Sep 17 00:00:00 2001 From: Jong Date: Tue, 7 Nov 2023 08:30:46 -0600 Subject: [PATCH 4/4] HGI-4481 - added error and msg --- target_sftp/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target_sftp/__init__.py b/target_sftp/__init__.py index 88db0d4..c8984d8 100644 --- a/target_sftp/__init__.py +++ b/target_sftp/__init__.py @@ -59,7 +59,7 @@ def upload(args): sftp_client.chdir(dir) except Exception as e: logger.info(f"Failed to create folder path at {sftp_client.getcwd()}. Folder skipped {dir}. Error message {e}") - raise NotADirectoryError + raise NotADirectoryError(e) for root, dirs, files in os.walk(config["input_path"]):