Skip to content

Commit

Permalink
change cli.py to grab method details from env file
Browse files Browse the repository at this point in the history
  • Loading branch information
sparul93 committed Feb 26, 2024
1 parent 41702d2 commit ebbcde9
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,42 @@
def main():
# Load Environmental Variables

"""
Assign environment variabled to call the desired method for file transfer.
Can also opt to use the method directly such as:
from_conn = ConnectionDetails(
method = FilepassMethod.SMB
)
"""
from_protocol = os.environ.get("FROMMETHOD").upper()

if from_protocol == "SMB":
from_method = FilepassMethod.SMB
elif from_protocol == "SFTP":
from_method = FilepassMethod.SFTP
elif from_protocol == "LOCAL":
from_method = FilepassMethod.LOCAL
else:
raise ValueError(
f"Unsupported Connection Method from: {from_protocol}. \n Please choose a supported method: SFTP, SMB or LOCAL."
)

to_protocol = os.environ.get("TOMETHOD").upper()

if to_protocol == "SMB":
to_method = FilepassMethod.SMB
elif to_protocol == "SFTP":
to_method = FilepassMethod.SFTP
elif to_protocol == "LOCAL":
to_method = FilepassMethod.LOCAL
else:
raise ValueError(
f"Unsupported Connection Method to: {to_protocol}. \n Please choose a supported method: SFTP, SMB or LOCAL."
)

# Connection objects
from_conn = ConnectionDetails(
method=FilepassMethod.SFTP,
method=from_method,
user=os.environ.get("FROMUSER"),
password=os.environ.get("FROMPW"),
server=os.environ.get("FROMSVR"),
Expand All @@ -22,7 +55,7 @@ def main():
)

to_conn = ConnectionDetails(
method=FilepassMethod.SMB,
method=to_method,
user=os.environ.get("TOUSER"),
password=os.environ.get("TOPW"),
server=os.environ.get("TOSVR"),
Expand Down

0 comments on commit ebbcde9

Please sign in to comment.