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

Insufficient removal of control characters on windows with cmd.exe as shell #82

Open
mf01 opened this issue Jul 12, 2022 · 2 comments
Open

Comments

@mf01
Copy link

mf01 commented Jul 12, 2022

Affected Line

endpoint = output.strip().decode("utf-8")

endpoint = output.strip().decode("utf-8")
Affected Version: at least since 0.10.3

I use PyCharm on Windows 10 to debug my pytest test cases. Starting the conatiners the above line is executed to to resolve a port for a service.

output = self._docker_compose.execute("port %s %d" % (service, container_port)) results to b'0.0.0.0:12347\r\n\x1b[0m'. No control character is removed. Hence, output.strip().decode("utf-8") result to s string including the control characters.

Some lines later (L86) if len(endpoint.split("\n")) > 1: does not support windows line endings.

On Linux or Git Bash for Windows, there is no problem.

My fix for that. Please check this solution:

endpoint = endpoint.replace("\r",'') # add support for windows line ending
if len(endpoint.split("\n")) > 1:
      endpoint = endpoint.split("\n")[-1] # index -1 is also wrong for me because it results to '\x1b[0m'. Maybe use 0 or -2
@wickywaka
Copy link

I can confirm this issue. I faced a similar problem in setting up and almost gave up on it. Any suggestions for a fix? I can do the grunt work to make the merge request.

@wickywaka
Copy link

For those who come here to find a solution for this problem, here is a related merge request:
#81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants