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

saving the response to file on MacOS add random characters #210

Open
tonythebest opened this issue Sep 25, 2020 · 4 comments
Open

saving the response to file on MacOS add random characters #210

tonythebest opened this issue Sep 25, 2020 · 4 comments

Comments

@tonythebest
Copy link

tonythebest commented Sep 25, 2020

print(result, file=ofile)

This line saves the response to a local file. My code calls this method but it adds some bad chars on MacOS (Macbook). The Windows machine has no issue. The additional bad chars are like: “0;36m”

@tonythebest
Copy link
Author

tonythebest commented Sep 29, 2020

[ESC][0;36mgood.com[ESC][0;0m:
[ESC][0;1;33mgood[ESC][0;0m

@tonythebest
Copy link
Author

tonythebest commented Oct 13, 2020

These chars are probably the definition of colors?
https://bluesock.org/~willkg/dev/ansi.html

@tonythebest
Copy link
Author

@gtmanfred Can you take a look at why

print(result, file=ofile)
adds color code like [ESC][0;36m when printing to a file on macOS

https://stackoverflow.com/questions/6159900/correct-way-to-write-line-to-file
is "print" used here because we want it to be compatible with python2? Can we use f.write?

Thank you.

@gtmanfred
Copy link
Contributor

I do not know why print was used here, probably just to be consistent across the board. I also do not know why it would be putting those escape codes.

Also I am no longer involved with maintaining the any projects in the salt community @mattp- might be able to help you. Otherwise you can try joining the saltstack slack or irc and ask there.

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