DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] dts: fix ssh timeout and output
@ 2022-10-27 14:09 Juraj Linkeš
  0 siblings, 0 replies; only message in thread
From: Juraj Linkeš @ 2022-10-27 14:09 UTC (permalink / raw)
  Cc: dev, Juraj Linkeš

We were always waiting the full timeout because we always waited for
the MAGIC_PROMPT, which is only usable for cleaning the session of
previous data. That also meant that the actual prompt was appended to
the output, resulting in output being '[PEXPECT]#' when the executed
command produced empty output. Both are fixed by using the MAGIC_PROMPT
only in self._clean_session.

Fixes: e81a070a1c7d ("dts: add ssh session module")

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
 dts/framework/remote_session/ssh_session.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dts/framework/remote_session/ssh_session.py b/dts/framework/remote_session/ssh_session.py
index f71acfb1ca..dc37e9772b 100644
--- a/dts/framework/remote_session/ssh_session.py
+++ b/dts/framework/remote_session/ssh_session.py
@@ -116,7 +116,9 @@ def send_expect_base(self, command: str, prompt: str, timeout: float) -> str:
         return before
 
     def _clean_session(self) -> None:
+        self.session.PROMPT = self.magic_prompt
         self.get_output(timeout=0.01)
+        self.session.PROMPT = self.session.UNIQUE_PROMPT
 
     def _send_line(self, command: str) -> None:
         if not self.is_alive():
@@ -134,7 +136,6 @@ def get_output(self, timeout: float = 15) -> str:
         """
         Get all output before timeout
         """
-        self.session.PROMPT = self.magic_prompt
         try:
             self.session.prompt(timeout)
         except Exception:
@@ -143,7 +144,6 @@ def get_output(self, timeout: float = 15) -> str:
         before = self._get_output()
         self._flush()
 
-        self.logger.debug(before)
         return before
 
     def _get_output(self) -> str:
-- 
2.30.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-27 14:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 14:09 [PATCH v1] dts: fix ssh timeout and output Juraj Linkeš

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).