Skip to content

Commit c7751c1

Browse files
author
Pan
committed
Updated paramiko client SFTP remote path manipulation for cross platform compatibility.
1 parent 21e4865 commit c7751c1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pssh/ssh_client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def copy_file(self, local_file, remote_file, recurse=False,
400400
raise ValueError("Recurse must be true if local_file is a "
401401
"directory.")
402402
sftp = self._make_sftp() if not sftp else sftp
403-
destination = self._parent_paths_split(remote_file)
403+
destination = self._parent_paths_split(remote_file, sep='/')
404404
try:
405405
sftp.stat(destination)
406406
except IOError:
@@ -476,13 +476,14 @@ def _make_local_dir(self, dirpath):
476476
"directory %s", dirpath)
477477
raise
478478

479-
def _parent_paths_split(self, file_path):
479+
def _parent_paths_split(self, file_path, sep=None):
480+
sep = os.path.sep if sep is None else sep
480481
try:
481-
destination = os.path.sep.join(
482+
destination = sep.join(
482483
[_dir for _dir in file_path.split(os.path.sep)
483484
if _dir][:-1])
484485
except IndexError:
485486
destination = ''
486-
if file_path.startswith(os.path.sep) or not destination:
487-
destination = os.path.sep + destination
487+
if file_path.startswith(sep) or not destination:
488+
destination = sep + destination
488489
return destination

0 commit comments

Comments
 (0)