I am wrapping a GUI tool around a command line tool in python and I am using subprocess module.
process = subprocess.Popen(
args, stdout=subprocess.PIP, encoding='utf8',
)
while True:
output = process.stdout.readline()
if output == b"" and process.poll() is not None:
print("BREAKING")
break
if output:
print(f'stdout: {output.strip()}')
result_code = process.poll()
print(f"result_code: {result_code }")
I am trying to read all output from the console, but with subprocess.PIPE
I can only read part of it.
Below is output from wrapper script using subprocess:
Below is output I want to read:
Using the stdout=subprocess.PIPE
, it does not include the Download 9%, Download 12%
etc.
How can I also capture this sys output?
I've tried using stdout=sys.stdout
, this will output evertything but I can't read from it like process.stdout.readline()
to handle the output.