From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D6586A04DD; Thu, 2 Jan 2020 04:23:44 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B0A901BF8E; Thu, 2 Jan 2020 04:23:44 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 10BF01BF83 for ; Thu, 2 Jan 2020 04:23:42 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jan 2020 19:23:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,385,1571727600"; d="scan'208";a="369218873" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga004.jf.intel.com with ESMTP; 01 Jan 2020 19:23:41 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 1 Jan 2020 19:23:41 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.197]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.55]) with mapi id 14.03.0439.000; Thu, 2 Jan 2020 11:23:39 +0800 From: "Chen, Zhaoyan" To: "Ma, LihongX" , "dts@dpdk.org" CC: "Chen, Zhaoyan" Thread-Topic: [dts][PATCH V1 2/4] framework/ssh: add params to ssh scp function Thread-Index: AQHVvId9wtvNpc31m0qulsXXt08MEafWvvag Date: Thu, 2 Jan 2020 03:23:39 +0000 Message-ID: <9DEEADBC57E43F4DA73B571777FECECA41E76C4D@SHSMSX104.ccr.corp.intel.com> References: <1577404987-1369-1-git-send-email-lihongx.ma@intel.com> <1577404987-1369-2-git-send-email-lihongx.ma@intel.com> In-Reply-To: <1577404987-1369-2-git-send-email-lihongx.ma@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1 2/4] framework/ssh: add params to ssh scp function 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Acked-by: Zhaoyan Chen Regards, Zhaoyan Chen > -----Original Message----- > From: Ma, LihongX > Sent: Friday, December 27, 2019 8:03 AM > To: dts@dpdk.org > Cc: Chen, Zhaoyan ; Ma, LihongX > Subject: [dts][PATCH V1 2/4] framework/ssh: add params to ssh scp functio= n >=20 > add parameter crb_session to copy_file_from/to, when the parameter is not= None, > will copy file from/to the crb session, otherwise will copy file from/to = current dts > env. >=20 > Signed-off-by: lihong > --- > framework/ssh_connection.py | 8 ++++---- > framework/ssh_pexpect.py | 27 +++++++++++++++++---------- > 2 files changed, 21 insertions(+), 14 deletions(-) >=20 > diff --git a/framework/ssh_connection.py b/framework/ssh_connection.py in= dex > 312139e..afeef1c 100644 > --- a/framework/ssh_connection.py > +++ b/framework/ssh_connection.py > @@ -108,8 +108,8 @@ class SSHConnection(object): >=20 > return True >=20 > - def copy_file_from(self, src, dst=3D".", password=3D''): > - self.session.copy_file_from(src, dst, password) > + def copy_file_from(self, src, dst=3D".", password=3D'', crb_session= =3DNone): > + self.session.copy_file_from(src, dst, password, crb_session) >=20 > - def copy_file_to(self, src, dst=3D"~/", password=3D''): > - self.session.copy_file_to(src, dst, password) > + def copy_file_to(self, src, dst=3D"~/", password=3D'', crb_session= =3DNone): > + self.session.copy_file_to(src, dst, password, crb_session) > diff --git a/framework/ssh_pexpect.py b/framework/ssh_pexpect.py index > df8da8a..979327c 100644 > --- a/framework/ssh_pexpect.py > +++ b/framework/ssh_pexpect.py > @@ -163,7 +163,7 @@ class SSHPexpect(object): > def isalive(self): > return self.session.isalive() >=20 > - def copy_file_from(self, src, dst=3D".", password=3D''): > + def copy_file_from(self, src, dst=3D".", password=3D'', crb_session= =3DNone): > """ > Copies a file from a remote place into local. > """ > @@ -172,11 +172,11 @@ class SSHPexpect(object): > command =3D 'scp -v -P {0} -o NoHostAuthenticationForLocalho= st=3Dyes > {1}@{2}:{3} {4}'.format( > str(self.port), self.username, self.ip, src, dst) > if password =3D=3D '': > - self._spawn_scp(command, self.password) > + self._spawn_scp(command, self.password, crb_session) > else: > - self._spawn_scp(command, password) > + self._spawn_scp(command, password, crb_session) >=20 > - def copy_file_to(self, src, dst=3D"~/", password=3D''): > + def copy_file_to(self, src, dst=3D"~/", password=3D'', crb_session= =3DNone): > """ > Sends a local file to a remote place. > """ > @@ -188,16 +188,23 @@ class SSHPexpect(object): > command =3D 'scp -v {0} {1}@{2}:{3}'.format( > src, self.username, self.host, dst) > if password =3D=3D '': > - self._spawn_scp(command, self.password) > + self._spawn_scp(command, self.password, crb_session) > else: > - self._spawn_scp(command, password) > + self._spawn_scp(command, password, crb_session) >=20 > - def _spawn_scp(self, scp_cmd, password): > + def _spawn_scp(self, scp_cmd, password, crb_session): > """ > Transfer a file with SCP > """ > self.logger.info(scp_cmd) > - p =3D pexpect.spawn(scp_cmd) > + # if crb_session is not None, copy file from/to crb env > + # if crb_session is None, copy file from/to current dts env > + if crb_session is not None: > + crb_session.session.clean_session() > + crb_session.session.__sendline(scp_cmd) > + p =3D crb_session.session.session > + else: > + p =3D pexpect.spawn(scp_cmd) > time.sleep(0.5) > ssh_newkey =3D 'Are you sure you want to continue connecting' > i =3D p.expect([ssh_newkey, '[pP]assword', "# ", pexpect.EOF, @@= -212,5 +219,5 > @@ class SSHPexpect(object): > p.expect("Exit status 0", 60) > if i =3D=3D 4: > self.logger.error("SCP TIMEOUT error %d" % i) > - > - p.close() > + if crb_session is None: > + p.close() > -- > 2.7.4