-
-
Save kleisauke/4fc7a7c1af8ca09e1fc03f0668d9063a to your computer and use it in GitHub Desktop.
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 sys | |
import subprocess | |
def eprint(*args, **kwargs): | |
print(*args, file=sys.stderr, **kwargs) | |
def etrace(str): | |
eprint("[TRACE] ", str) | |
args = sys.argv[1:] | |
process = subprocess.Popen(args, | |
stdout=subprocess.PIPE, | |
stderr=sys.stderr, | |
stdin=subprocess.PIPE, | |
universal_newlines=True) | |
etrace(args) | |
for input in sys.stdin: | |
if "invalid_request" in input: | |
continue | |
etrace(input.strip()) | |
process.stdin.write(input) | |
process.stdin.close() | |
etrace("Done sending input...") | |
for output in process.stdout.readlines(): | |
etrace("Printing output...") | |
etrace(output.strip()) | |
print(output.strip()) | |
etrace("Done receiving output...") | |
return_code = process.poll() | |
etrace("Return code: " + str(return_code)) | |
exit(return_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment