BugFix: remotepath cannot be found 71/26271/2
authorJingLu5 <lvjing5@huawei.com>
Tue, 20 Dec 2016 02:46:26 +0000 (10:46 +0800)
committerJingLu5 <lvjing5@huawei.com>
Tue, 20 Dec 2016 03:08:02 +0000 (11:08 +0800)
JIRA: YARDSTICK-501

An redundant pair of quotation in ssh.py causes remotepath cannot be found.

Change-Id: I2df8ab59830fd28d8ad8882a93a8efbd4d1f7cb7
Signed-off-by: JingLu5 <lvjing5@huawei.com>
tests/unit/test_ssh.py
yardstick/ssh.py

index 88638a0..8b828ed 100644 (file)
@@ -314,7 +314,7 @@ class SSHRunTestCase(unittest.TestCase):
         self.test_client._put_file_shell("localfile", "remotefile", 0o42)
 
         self.test_client.run.assert_called_once_with(
-            'cat > "remotefile"&& chmod -- 042 "remotefile"',
+            'cat > remotefile && chmod -- 042 remotefile',
             stdin=mock_open.return_value.__enter__.return_value)
 
     @mock.patch("yardstick.ssh.os.stat")
index 2ba6de9..3081001 100644 (file)
@@ -313,14 +313,14 @@ class SSH(object):
 
     def _put_file_shell(self, localpath, remotepath, mode=None):
         # quote to stop wordpslit
-        cmd = ['cat > "%s"' % remotepath]
+        cmd = ['cat > %s' % remotepath]
         if mode is not None:
             # use -- so no options
-            cmd.append('chmod -- 0%o "%s"' % (mode, remotepath))
+            cmd.append('chmod -- 0%o %s' % (mode, remotepath))
 
         with open(localpath, "rb") as localfile:
             # only chmod on successful cat
-            cmd = "&& ".join(cmd)
+            cmd = " && ".join(cmd)
             self.run(cmd, stdin=localfile)
 
     def put_file(self, localpath, remotepath, mode=None):