1import subprocess
2import sys
3
4process = subprocess.Popen(cmdCommand, shell = True,bufsize = 1,
5 stdout=subprocess.PIPE, stderr = subprocess.STDOUT,encoding='utf-8', errors = 'replace' )
6while True:
7 realtime_output = process.stdout.readline()
8 if realtime_output == '' and process.poll() is not None:
9 break
10 if realtime_output:
11 print(realtime_output.strip(), flush=False)
12 sys.stdout.flush()