[dts] [PATCH] framework: send command without expect specific string return
Yong Liu
yong.liu at intel.com
Wed Sep 30 07:37:29 CEST 2015
From: Marvin Liu <yong.liu at intel.com>
Implement new function which only send command and not expect certain string.
Function send_command will return all output in session between timeout.
Signed-off-by: Marvin Liu <yong.liu at intel.com>
diff --git a/framework/crb.py b/framework/crb.py
index 5434531..fcbd7d9 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -69,6 +69,16 @@ class Crb(object):
return self.session.send_expect(cmds, expected, timeout, verify)
+ def send_command(self, cmds, timeout=TIMEOUT, alt_session=False):
+ """
+ Send commands to crb and return string before timeout.
+ """
+
+ if alt_session:
+ return self.alt_session.session.send_command(cmds, timeout)
+
+ return self.session.send_command(cmds, timeout)
+
def get_session_output(self, timeout=TIMEOUT):
"""
Get session output message before timeout
diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py
index 63b8785..9f1aee1 100644
--- a/framework/ssh_connection.py
+++ b/framework/ssh_connection.py
@@ -61,6 +61,12 @@ class SSHConnection(object):
self.logger.debug(out)
return out
+ def send_command(self, cmds, timeout=1):
+ self.logger.info(cmds)
+ out = self.session.send_command(cmds)
+ self.logger.debug(out)
+ return out
+
def get_session_before(self, timeout=15):
out = self.session.get_session_before(timeout)
self.logger.debug(out)
diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py
index 2951cf3..046692f 100644
--- a/framework/ssh_pexpect.py
+++ b/framework/ssh_pexpect.py
@@ -46,7 +46,7 @@ class SSHPexpect(object):
def send_expect_base(self, command, expected, timeout):
ignore_keyintr()
- self.__flush() # clear buffer
+ self.clean_session()
self.session.PROMPT = expected
self.__sendline(command)
self.__prompt(command, timeout)
@@ -68,6 +68,16 @@ class SSHPexpect(object):
else:
return ret
+ def send_command(self, command, timeout=1):
+ ignore_keyintr()
+ self.clean_session()
+ self.__sendline(command)
+ aware_keyintr()
+ return self.get_session_before(timeout)
+
+ def clean_session(self):
+ self.get_session_before(timeout=0.01)
+
def get_session_before(self, timeout=15):
"""
Get all output before timeout
--
1.9.3
More information about the dts
mailing list