From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3011543E92; Wed, 17 Apr 2024 15:18:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 121B640E32; Wed, 17 Apr 2024 15:18:27 +0200 (CEST) Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by mails.dpdk.org (Postfix) with ESMTP id 7021640ED9 for ; Wed, 17 Apr 2024 15:18:24 +0200 (CEST) Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a52aa665747so409463766b.2 for ; Wed, 17 Apr 2024 06:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1713359904; x=1713964704; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=46NN2Fyjp1RwEW/aTnnnzN7TYtblfFyC7cYQYODLalI=; b=gY3FdAQP+bqggaKyI0BOESUKVh1bK0JmQqT0W0z3+TMDQRCy0PKC3dJmx3Jg78Eh8H A/OsgdtHf9y9DJ8/ng0cU3n0PxX3KbTUXMxDy9wFwzk2M23NxsWOIU8snTaS6tiTqdWw 5n2XWojN2AdOD6cOmXVbP0eEKQWPpQ9i642GbEQPri5ymg+4PuKFWRhcF5dsLqpxlhAy JRYRiEgtxZDZpwm65hdsKI8jF5PwGVoAIOBySUF7Fwlfij+RHwgxCugYzH49plil4nqT vk7fK4Pq4CBfxhZGc+Hb1QghmLOG97msE/4L2OvZgLyJzb80XN+3Mgyq9MgRdfyYEPHP s1Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713359904; x=1713964704; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=46NN2Fyjp1RwEW/aTnnnzN7TYtblfFyC7cYQYODLalI=; b=WHs6ZfoFtOzNNKJlnE69ulENzRDTZ6FWQRC0jC3pvaPms6N1KseTAVps7oUDfuECpz oNVxJTXE4r88wwNSg/RTkOR/Qkb1R3kfyPQ1fro7F+KOpeolJIEVgsSM/bhYbcszSg7b rkAhC8izqb7kdCoOEFxA22NRT8YiJvJvVvo0GbKZz3lFY4DbI7h03XqdDPGjm10ienLV L3Owr44AecDkxq+/E58XjEIMRz3BGj9zFHucC5b+RC81wRzP6uFyKAzQpetMWSeJBGSj O5M9CPNNQ7bz/mwX8vGIj2KbsdL+exZQw1EtB1ROHntHtL26DL/hQSWO6X0N0elDpvaG 8Bmg== X-Gm-Message-State: AOJu0YyGyq0KwkbwFGpTALJYtyfiNNNIMlDD9KgG1GO1OWjf8vY7NWqm Y6R/nE2H0QrlqdFZS+PdAYJ+T/42a8doat9pcMVDRxx6WUnxZfqdqyT8Cvkjt2cjd31iUKr08dF RES0TT48KPLx3cgWE46AjZZQ/7s4vrodFY2XAag== X-Google-Smtp-Source: AGHT+IH4yJh4RPukNTtd/Fe3nrBWgSPjWN23voqv5yDf42gVqJwQcqR2M/NSIjClgbQEc9YQK30a1Fm1UQJWI67mrmE= X-Received: by 2002:a17:906:1589:b0:a51:b1b1:b772 with SMTP id k9-20020a170906158900b00a51b1b1b772mr8943637ejd.65.1713359904235; Wed, 17 Apr 2024 06:18:24 -0700 (PDT) MIME-Version: 1.0 References: <20240412111136.3470304-1-luca.vizzarro@arm.com> <20240412111136.3470304-3-luca.vizzarro@arm.com> <743fd932-1192-42ac-ab5b-27ac5b7e56ed@arm.com> In-Reply-To: <743fd932-1192-42ac-ab5b-27ac5b7e56ed@arm.com> From: =?UTF-8?Q?Juraj_Linke=C5=A1?= Date: Wed, 17 Apr 2024 15:18:13 +0200 Message-ID: Subject: Re: [PATCH 2/5] dts: skip first line of send_command output To: Luca Vizzarro Cc: dev@dpdk.org, Jeremy Spewock , Paul Szczepanek , Jack Bond-Preston Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Tue, Apr 16, 2024 at 2:15=E2=80=AFPM Luca Vizzarro wrote: > > On 16/04/2024 09:48, Juraj Linke=C5=A1 wrote: > > Oh, the first commit message was confusing. It said leading prompt > > which I understood to be the first prompt (the one with the command). > > I see that this commit actually addresses what I thought the first > > commit was trying to do. > > Yes, my bad! > > >> - def send_command(self, command: str, prompt: str | None =3D None)= -> str: > >> + def send_command( > >> + self, command: str, prompt: str | None =3D None, skip_first_l= ine: bool =3D False > > > > Do we generally want or don't want to include the first line? When do > > we absolutely not want to include it? > > In the case of `show port info/stats {x}` if the provided port is > invalid, then the first message starts with `Invalid port`. By providing > an output that skips the command prompt, this is easily checked with > output.startswith("Invalid port") as you may have noticed in the next > commit. Otherwise it'd be a bit more complicated. Personally, I am not > sure whether we care about the first line. With my limited knowledge I > don't see a reason to include it (just as much as the trailing prompt). > > >> + ) -> str: > >> """Send `command` and get all output before the expected end= ing string. > >> > >> Lines that expect input are not included in the stdout buffe= r, so they cannot > >> @@ -121,6 +123,7 @@ def send_command(self, command: str, prompt: str |= None =3D None) -> str: > >> command: The command to send. > >> prompt: After sending the command, `send_command` will b= e expecting this string. > >> If :data:`None`, will use the class's default prompt= . > >> + skip_first_line: Skip the first line when capturing the o= utput. > >> > >> Returns: > >> All output in the buffer before expected string. > >> @@ -132,6 +135,9 @@ def send_command(self, command: str, prompt: str |= None =3D None) -> str: > >> self._stdin.flush() > >> out: str =3D "" > >> for line in self._stdout: > >> + if skip_first_line: > >> + skip_first_line =3D False > >> + continue > > > > Is there ever a reason to distinguish between the first line and the > > line with the command on it? > > As above, not really sure. Would this always be a command prompt? The > doubt arises only because I don't understand why we'd need the command > prompt fed back. > The only thing I could think of is debugging. Maybe it could offer some extra insight in some corner cases. > > > >> if prompt in line and not line.rstrip().endswith( > >> command.rstrip() > >> ): # ignore line that sent command > >> -- > >> 2.34.1 > >> >