[dts] [PATCH 2/2] framework/ssh: Add destination available for file copy function
Michael Qiu
michael.qiu at intel.com
Wed Feb 11 13:26:25 CET 2015
For file copy in ssh module, the destination is fixed.
This patch make it configurable.
Signed-off-by: Michael Qiu <michael.qiu at intel.com>
---
framework/ssh_connection.py | 8 ++++----
framework/ssh_pexpect.py | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
index 25f249a..f86b3b5 100644
--- a/framework/ssh_connection.py
+++ b/framework/ssh_connection.py
@@ -61,8 +61,8 @@ class SSHConnection(object):
def isalive(self):
return self.session.isalive()
- def copy_file_from(self, filename, password=''):
- self.session.copy_file_from(filename, password)
+ def copy_file_from(self, src, dst = ".", password=''):
+ self.session.copy_file_from(src, dst, password)
- def copy_file_to(self, filename, password=''):
- self.session.copy_file_to(filename, password)
+ def copy_file_to(self, src, dst = "~/", password=''):
+ self.session.copy_file_to(src, dst, password)
diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 9c353e7..8f8c982 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -66,21 +66,21 @@ class SSHPexpect(object):
def isalive(self):
return self.session.isalive()
- def copy_file_from(self, filename, password=''):
+ def copy_file_from(self, src, dst = ".", password=''):
"""
Copies a file from a remote place into local.
"""
- command = 'scp {0}@{1}:{2} .'.format(self.username, self.host, filename)
+ command = 'scp {0}@{1}:{2} {3}'.format(self.username, self.host, src, dst)
if password == '':
self._spawn_scp(command, self.password)
else:
self._spawn_scp(command, password)
- def copy_file_to(self, filename, password=''):
+ def copy_file_to(self, src, dst = "~/", password=''):
"""
Sends a local file to a remote place.
"""
- command = 'scp {0} {1}@{2}:'.format(filename, self.username, self.host)
+ command = 'scp {0} {1}@{2}:{3}'.format(src, self.username, self.host, dst)
if password == '':
self._spawn_scp(command, self.password)
else:
--
1.9.3
More information about the dts
mailing list