Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing escape sequence from output in cmd_output function! #142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion aexpect/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
Loading