Thank you for your review Juraj!
On 16/04/2024 09:40, Juraj Linkeš wrote:
When sending a command using an instance of InteractiveShell the output
is meant to filter out the leading shell prompt. The filtering logic is
present but the line is appended anyways.
I don't think that's what's happening here. The output collecting
logic is "stop when we encounter a prompt, but not the prompt with the
command we sent". We could change the comment though.
Yeah, I actually identified the behaviour better after writing this.
Will update the commit body accordingly. And I mixed-up leading with
trailing! This is meant to say "trailing shell prompt".
@@ -132,11 +132,11 @@ def send_command(self, command: str, prompt: str | None =
None) -> str:
self._stdin.flush()
out: str = ""
for line in self._stdout:
- out += line
if prompt in line and not line.rstrip().endswith(
command.rstrip()
): # ignore line that sent command
break
+ out += line
If we do this, we'll only filter out the last prompt, which may not be
desirable, since the last prompt is there only because all of our
interactive shells force an extra prompt with _command_extra_chars.
Could you please expand more on this?
One thing we could improve though is removing the distribution welcome
message from logs, or at least separate it from the first command sent
with the interactive shell. The second option will allow us to see
clearly that an interactive session has been established, although we
could just emit a shorter log (something like "Started a testpmd
session" and then flush the welcome screen output).
I am not sure what you are referring to exactly, could you also expand
more on this please?
Given it's not particularly explained, I thought having two command
prompts (especially a trailing one) was an error. The main reason behind
this is that when we go to parse the port info, the last entry which is
"device private info" appears to be open ended, and I couldn't gather
much information from the testpmd source code. So I opted to parse
everything until the end. With a trailing command prompt this meant
that: device_private_info="....testpmd> ".