From 907b65a9904778bd76be9e4a4d46f09c0327d3d1 Mon Sep 17 00:00:00 2001 From: Anushree Mathur Date: Mon, 6 Jan 2025 01:01:12 +0530 Subject: [PATCH] Removing escape sequence from output in cmd_output function! In console outputs we are getting escape sequences because of which most of the testcases are failing to use the output of few commands. This PR removes the escape sequence first then use the output.This PR fixes multiple testcases. Signed-off-by: Anushree Mathur --- aexpect/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aexpect/client.py b/aexpect/client.py index e0460f4..6996897 100644 --- a/aexpect/client.py +++ b/aexpect/client.py @@ -1218,6 +1218,8 @@ def cmd_output(self, cmd, timeout=60, internal_timeout=None, self.sendline(cmd) try: out = self.read_up_to_prompt(timeout, internal_timeout, print_func) + # Removing escape sequence from output! + out_no_escape = astring.strip_console_codes(out) except ExpectTimeoutError as error: output = self.remove_command_echo(error.output, cmd) raise ShellTimeoutError(cmd, output) from error @@ -1229,7 +1231,7 @@ def cmd_output(self, cmd, timeout=60, internal_timeout=None, raise ShellError(cmd, output) from error # Remove the echoed command and the final shell prompt - return self.remove_last_nonempty_line(self.remove_command_echo(out, + return self.remove_last_nonempty_line(self.remove_command_echo(out_no_escape, cmd)) def cmd_output_safe(self, cmd, timeout=60):