[PATCH v2 1/3] dts: Improve output gathering in interactive shells
Jeremy Spewock
jspewock at iol.unh.edu
Wed May 15 21:13:50 CEST 2024
On Mon, May 13, 2024 at 10:58 AM Juraj Linkeš
<juraj.linkes at pantheon.tech> wrote:
>
> Other than the one minor documentation nitpick,
> Reviewed-by: Juraj Linkeš <juraj.linkes at pantheon.tech>
>
> <snip>
> > diff --git a/dts/framework/remote_session/interactive_shell.py b/dts/framework/remote_session/interactive_shell.py
>
> > @@ -124,20 +130,34 @@ def send_command(self, command: str, prompt: str | None = None) -> str:
<snip>
> > - self._stdin.write(f"{command}{self._command_extra_chars}\n")
> > - 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
> > - self._logger.debug(f"Got output: {out}")
> > + try:
> > + self._stdin.write(f"{command}{self._command_extra_chars}\n")
> > + self._stdin.flush()
> > + for line in self._stdout:
> > + out += line
> > + if line.rstrip().endswith(prompt):
> > + break
>
> We should document the (currently) hidden assumption of us needing to
> use the extra command chars to force another prompt in the docstring.
>
This is a good point, it is mostly internal knowledge currently so it
would be good to explain this more. I'll add it to the comment
documenting what the class var is for.
<snip>
> > 2.44.0
> >
More information about the dev
mailing list