Skip to content

Commit

Permalink
Add mkdir parameter to put_dir method in sftp_interface class
Browse files Browse the repository at this point in the history
  • Loading branch information
RichieHakim committed Feb 5, 2024
1 parent 7dd635f commit c2e518f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bnpm/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def connect(
self.transport.connect(None, username, password) ## authorization
self.sftp = paramiko.SFTPClient.from_transport(self.transport) ## open sftp

def put_dir(self, source, target, verbose=True):
def put_dir(self, source, target, mkdir=True, verbose=True):
'''
Uploads the contents of the source directory to the target path.
All subdirectories in source are created under target recusively.
Expand All @@ -579,10 +579,15 @@ def put_dir(self, source, target, verbose=True):
Path to the source directory (local).
target (str):
Path to the target directory (remote).
mkdir (bool):
Make the target directory if it does not exist.
'''
source = Path(source).resolve()
target = Path(target).resolve()

if mkdir:
self.mkdir_safe(str(target), ignore_existing=True)

for item in os.listdir(source):
if os.path.isfile(source / item):
if verbose:
Expand Down

0 comments on commit c2e518f

Please sign in to comment.