From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id E4875C636 for ; Tue, 28 Apr 2015 16:56:44 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 28 Apr 2015 07:56:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,664,1422950400"; d="scan'208";a="720498639" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 28 Apr 2015 07:56:43 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t3SEufNl029887; Tue, 28 Apr 2015 22:56:41 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t3SEucLN006848; Tue, 28 Apr 2015 22:56:40 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t3SEucfv006844; Tue, 28 Apr 2015 22:56:38 +0800 From: Yong Liu To: dts@dpdk.org Date: Tue, 28 Apr 2015 22:56:30 +0800 Message-Id: <1430232992-6798-3-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1430232992-6798-1-git-send-email-yong.liu@intel.com> References: <1430232992-6798-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 2/4] framework: maintain connected session list and disable debug mode in send_expect X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Apr 2015 14:56:45 -0000 From: Marvin Liu Signed-off-by: Marvin Liu --- framework/ssh_connection.py | 7 +++++++ framework/ssh_pexpect.py | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py index b10cb4f..18a6517 100644 --- a/framework/ssh_connection.py +++ b/framework/ssh_connection.py @@ -32,6 +32,10 @@ from ssh_pexpect import SSHPexpect from settings import USERNAME +""" +Global structure for saving connections +""" +CONNECTIONS = [] class SSHConnection(object): @@ -43,6 +47,9 @@ class SSHConnection(object): def __init__(self, host, session_name, password=''): self.session = SSHPexpect(host, USERNAME, password) self.name = session_name + connection = {} + connection[self.name] = self.session + CONNECTIONS.append(connection) def init_log(self, logger): self.logger = logger diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py index eaa3a42..735df44 100644 --- a/framework/ssh_pexpect.py +++ b/framework/ssh_pexpect.py @@ -1,6 +1,7 @@ import time import pexpect import pxssh +from debugger import ignore_keyintr, aware_keyintr from exception import TimeoutException, SSHConnectionException """ @@ -31,12 +32,15 @@ class SSHPexpect(object): self.logger.info("ssh %s@%s" % (self.username, self.host)) def send_expect_base(self, command, expected, timeout=15): - # clear buffer - self.__flush() + ignore_keyintr() + self.__flush() # clear buffer self.session.PROMPT = expected self.__sendline(command) self.__prompt(command, timeout) - return self.get_output_before() + aware_keyintr() + + before = self.get_output_before() + return before def send_expect(self, command, expected, timeout=15, verify=False): ret = self.send_expect_base(command, expected, timeout) -- 1.9.3