escape spaces in any type of path for mkdir/rm
Change-Id: Ic8757f31bb21850faaae2fc90809f0fed0df98e0
This commit is contained in:
parent
e2a7b8c811
commit
887368db3b
|
@ -932,10 +932,8 @@ class SSHClient(six.with_metaclass(_MemorizedSSH, object)):
|
|||
|
||||
def _path_esc(self, path):
|
||||
"""Escape space character in the path"""
|
||||
if type(path) is str:
|
||||
if path:
|
||||
return (path.replace(' ', '\ '))
|
||||
else:
|
||||
return path
|
||||
|
||||
def mkdir(self, path):
|
||||
"""run 'mkdir -p path' on remote
|
||||
|
|
|
@ -1797,7 +1797,8 @@ class TestSftp(unittest.TestCase):
|
|||
def test_mkdir(self, execute, exists, client, policy, logger):
|
||||
exists.side_effect = [False, True]
|
||||
|
||||
dst = '~/tst'
|
||||
dst = '~/tst dir'
|
||||
escaped_dst = '~/tst\ dir'
|
||||
|
||||
# noinspection PyTypeChecker
|
||||
ssh = ssh_client.SSHClient(
|
||||
|
@ -1812,7 +1813,7 @@ class TestSftp(unittest.TestCase):
|
|||
# noinspection PyTypeChecker
|
||||
ssh.mkdir(dst)
|
||||
exists.assert_called_once_with(dst)
|
||||
execute.assert_called_once_with("mkdir -p {}\n".format(dst))
|
||||
execute.assert_called_once_with("mkdir -p {}\n".format(escaped_dst))
|
||||
|
||||
# Path exists
|
||||
exists.reset_mock()
|
||||
|
|
Loading…
Reference in New Issue