From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH] framework: send command without expect specific string return
Date: Wed, 30 Sep 2015 13:37:29 +0800 [thread overview]
Message-ID: <1443591449-28581-1-git-send-email-yong.liu@intel.com> (raw)
From: Marvin Liu <yong.liu@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@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
reply other threads:[~2015-09-30 5:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443591449-28581-1-git-send-email-yong.liu@intel.com \
--to=yong.liu@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).