[dts] [PATCH] framework ssh_pexpect: fix scp file truncated issue

Yong Liu yong.liu at intel.com
Mon Jan 23 02:36:44 CET 2017


Some times even scp command status show 100%, file still not scp to
destination integrated. Enable verbose option and wait for scp process
really exited.

Signed-off-by: Yong Liu <yong.liu at intel.com>

diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index d5b6616..8d6c3dd 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -143,9 +143,9 @@ class SSHPexpect(object):
         """
         Copies a file from a remote place into local.
         """
-        command = 'scp {0}@{1}:{2} {3}'.format(self.username, self.host, src, dst)
+        command = 'scp -v {0}@{1}:{2} {3}'.format(self.username, self.host, src, dst)
         if ':' in self.host:
-            command = 'scp -P {0} -o NoHostAuthenticationForLocalhost=yes {1}@{2}:{3} {4}'.format(
+            command = 'scp -v -P {0} -o NoHostAuthenticationForLocalhost=yes {1}@{2}:{3} {4}'.format(
                 str(self.port), self.username, self.ip, src, dst)
         if password == '':
             self._spawn_scp(command, self.password)
@@ -158,10 +158,10 @@ class SSHPexpect(object):
         """
         command = 'scp {0} {1}@{2}:{3}'.format(src, self.username, self.host, dst)
         if ':' in self.host:
-            command = 'scp -P {0} -o NoHostAuthenticationForLocalhost=yes {1} {2}@{3}:{4}'.format(
+            command = 'scp -v -P {0} -o NoHostAuthenticationForLocalhost=yes {1} {2}@{3}:{4}'.format(
                 str(self.port), src, self.username, self.ip, dst)
         else:
-            command = 'scp {0} {1}@{2}:{3}'.format(
+            command = 'scp -v {0} {1}@{2}:{3}'.format(
                 src, self.username, self.host, dst)
         if password == '':
             self._spawn_scp(command, self.password)
@@ -185,7 +185,7 @@ class SSHPexpect(object):
         if i == 1:
             time.sleep(0.5)
             p.sendline(password)
-            p.expect("100%", 60)
+            p.expect("Exit status 0", 60)
         if i == 4:
             self.logger.error("SCP TIMEOUT error %d" % i)
 
-- 
1.9.3



More information about the dts mailing list