Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file existence check and logging in upload function #21

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions target_sftp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ def parse_args():


def upload(args):
logger.info("Checking if there is at least one file to upload...")
if not os.path.exists(args.config["input_path"]):
raise Exception(f"Input path {args.config['input_path']} does not exist")
has_files = False
for root, dirs, files in os.walk(args.config["input_path"]):
if len(files) > 0:
has_files = True
logger.info(f"Found {len(files)} files in {root}")
break
if not has_files:
logger.info(f"No files to upload in {args.config['input_path']}")
return

logger.info(f"Exporting data...")
config = args.config
# Upload all data in input_path to sftp
Expand Down