From patchwork Fri Apr 12 11:11:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Vizzarro X-Patchwork-Id: 139238 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8CB3C43E51; Fri, 12 Apr 2024 13:12:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3A7D406BA; Fri, 12 Apr 2024 13:11:55 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id 0E8D1400D6 for ; Fri, 12 Apr 2024 13:11:55 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B4772339; Fri, 12 Apr 2024 04:12:23 -0700 (PDT) Received: from localhost.localdomain (unknown [10.57.19.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 176973F766; Fri, 12 Apr 2024 04:11:52 -0700 (PDT) From: Luca Vizzarro To: dev@dpdk.org Cc: =?utf-8?q?Juraj_Linke=C5=A1?= , Jeremy Spewock , Luca Vizzarro , Paul Szczepanek , Jack Bond-Preston Subject: [PATCH 2/5] dts: skip first line of send_command output Date: Fri, 12 Apr 2024 12:11:33 +0100 Message-Id: <20240412111136.3470304-3-luca.vizzarro@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412111136.3470304-1-luca.vizzarro@arm.com> References: <20240412111136.3470304-1-luca.vizzarro@arm.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The first line of the InteractiveShell send_command method is generally the command input field. This sometimes is unwanted, therefore this commit enables the possibility of omitting the first line from the returned output. Signed-off-by: Luca Vizzarro Reviewed-by: Paul Szczepanek Reviewed-by: Jack Bond-Preston --- dts/framework/remote_session/interactive_shell.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dts/framework/remote_session/interactive_shell.py b/dts/framework/remote_session/interactive_shell.py index 8a9bf96ea9..e290a083e9 100644 --- a/dts/framework/remote_session/interactive_shell.py +++ b/dts/framework/remote_session/interactive_shell.py @@ -105,7 +105,9 @@ def _start_application(self, get_privileged_command: Callable[[str], str] | None start_command = get_privileged_command(start_command) self.send_command(start_command) - def send_command(self, command: str, prompt: str | None = None) -> str: + def send_command( + self, command: str, prompt: str | None = None, skip_first_line: bool = False + ) -> str: """Send `command` and get all output before the expected ending string. Lines that expect input are not included in the stdout buffer, so they cannot @@ -121,6 +123,7 @@ def send_command(self, command: str, prompt: str | None = None) -> str: command: The command to send. prompt: After sending the command, `send_command` will be expecting this string. If :data:`None`, will use the class's default prompt. + skip_first_line: Skip the first line when capturing the output. Returns: All output in the buffer before expected string. @@ -132,6 +135,9 @@ def send_command(self, command: str, prompt: str | None = None) -> str: self._stdin.flush() out: str = "" for line in self._stdout: + if skip_first_line: + skip_first_line = False + continue if prompt in line and not line.rstrip().endswith( command.rstrip() ): # ignore line that sent command