Skip to content

Commit e4b0865

Browse files
Kincaid Savoiepkittenis
authored andcommitted
Added statement to yell at the user if they don't set recurse and try to scp a directory.
1 parent aceadc9 commit e4b0865

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pssh/ssh_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ def copy_file_to_local(self, remote_file, local_file, recurse=False):
400400
:type local_file: str
401401
:param recurse: Whether or not to recursively copy directories.
402402
:type recurse: bool
403+
404+
:raises: :mod:'ValueError' when a directory is supplied to remote_file \
405+
and recurse is not set
403406
"""
404407
sftp = self._make_sftp()
405408
try:
@@ -409,6 +412,9 @@ def copy_file_to_local(self, remote_file, local_file, recurse=False):
409412
remote_dir_exists = False
410413
if remote_dir_exists and recurse:
411414
return self._copy_dir_to_local(remote_file, local_file)
415+
elif remote_dir_exists and not recurse:
416+
raise ValueError("Recurse must be true if local_file is a "
417+
"directory.")
412418
destination = [_dir for _dir in local_file.split(os.path.sep)
413419
if _dir][:-1][0]
414420
if local_file.startswith(os.path.sep):

0 commit comments

Comments
 (0)