Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
On 03/24/2014 03:33 PM, Aline Manera wrote:
From: Aline Manera <alinefm(a)br.ibm.com>
When updating the system, the user should be able to see the progress to know
what is being done in the system.
stdout.read() will wait until get the completed output to return, ie, the user
will see the progress only when the update finishs.
So use stdout.readline() to read line by line and display the info to
the user.
Signed-off-by: Aline Manera <alinefm(a)br.ibm.com>
---
src/kimchi/swupdate.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/kimchi/swupdate.py b/src/kimchi/swupdate.py
index 3238e44..356ec52 100644
--- a/src/kimchi/swupdate.py
+++ b/src/kimchi/swupdate.py
@@ -112,21 +112,27 @@ class SoftwareUpdate(object):
"""
Execute the update
"""
+ # reset messages
+ cb('')
+
cmd = self._pkg_mnger.update_cmd
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
msgs = []
while proc.poll() is None:
- msgs.append(proc.stdout.read())
- cb('\n'.join(msgs))
+ msgs.append(proc.stdout.readline())
+ cb(''.join(msgs))
time.sleep(0.5)
+ # read the final output lines
+ msgs.extend(proc.stdout.readlines())
+
retcode = proc.poll()
if retcode == 0:
- return cb('\n'.join(msgs), True)
+ return cb(''.join(msgs), True)
- msgs.append(proc.stderr.read())
- return cb('\n'.join(msgs), False)
+ msgs.extend(proc.stderr.readlines())
+ return cb(''.join(msgs), False)
class YumUpdate(object):