1
0
Fork 0
mirror of https://github.com/fastogt/pyfastogt synced 2025-03-09 23:38:55 +00:00

Fix process read

This commit is contained in:
topilski 2017-03-07 14:09:27 +03:00
parent 897270d3ef
commit 1550a660f0

View file

@ -109,13 +109,9 @@ def run_command_cb(cmd, policy):
try:
policy.update_progress_message(0.0, 'Command {0} started'.format(cmd))
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
while True:
output = process.stdout.readline()
if output == '' and process.poll() is not None:
break
if output:
for output in process.stdout:
line = output.strip()
policy.process(Message(line, MessageType.MESSAGE))
policy.process(Message(line.decode("utf-8"), MessageType.MESSAGE))
rc = process.poll()
policy.update_progress_message(100.0, 'Command {0} finished successfully'.format(cmd))
except subprocess.CalledProcessError as ex: