Last active
September 27, 2020 08:01
-
-
Save lubo/ac7686699f6b5a27873e462ad495c170 to your computer and use it in GitHub Desktop.
Fixes binary output in Salt highstate logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import ast | |
import fileinput | |
try: | |
for line in fileinput.input(): | |
line = line.rstrip('\n') | |
try: | |
line = ast.literal_eval(line).decode() | |
except (AttributeError, SyntaxError): | |
pass | |
try: | |
print(line) | |
except BrokenPipeError: | |
break | |
except KeyboardInterrupt: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment