aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gaffney <agaffney@gentoo.org>2005-10-21 04:31:01 +0000
committerAndrew Gaffney <agaffney@gentoo.org>2005-10-21 04:31:01 +0000
commit6793d5c7dd9499fb43437ee400d8bc40757c7ec3 (patch)
tree097419f33c8e290adc26197387d83da25d35471c
parentadd unpack progress to portage snapshot (diff)
downloadgli-6793d5c7dd9499fb43437ee400d8bc40757c7ec3.tar.gz
gli-6793d5c7dd9499fb43437ee400d8bc40757c7ec3.tar.bz2
gli-6793d5c7dd9499fb43437ee400d8bc40757c7ec3.zip
use read() instead of readlines() in spawn()
only update progress bar for whole percents git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/gli/trunk@982 f8877401-5920-0410-a79b-8e2d7e04ca0d
-rw-r--r--ChangeLog6
-rw-r--r--src/GLIUtility.py28
2 files changed, 23 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index b01ba20..6a1ff99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,16 @@
# ChangeLog for Gentoo Linux Installer
# Copyright 2005-2005 Gentoo Technologies, Inc.
-# $Header: /var/cvsroot/gentoo/src/installer/ChangeLog,v 1.429 2005/10/21 01:52:49 agaffney Exp $
+# $Header: /var/cvsroot/gentoo/src/installer/ChangeLog,v 1.430 2005/10/21 04:31:01 agaffney Exp $
*GLI-0.3 (17 Oct 2005)
20 Oct 2005; Andrew Gaffney <agaffney@gentoo.org>
- src/GLIUtility.py, src/GLIArchitectureTemplate.py:
+ src/GLIUtility.py:
horrible tangled mess of code that is tarball unpacking subprogress display
add unpack progress to portage snapshot
+ use read() instead of readlines() in spawn()
+ only update progress bar for whole percents
19 Oct 2005; Andrew Gaffney <agaffney@gentoo.org>
src/templates/x86ArchitectureTemplate.py:
diff --git a/src/GLIUtility.py b/src/GLIUtility.py
index 9f92915..2ae5050 100644
--- a/src/GLIUtility.py
+++ b/src/GLIUtility.py
@@ -320,27 +320,37 @@ def spawn(cmd, quiet=False, logfile=None, display_on_tty8=False, chroot=None, ap
# read a line from the pipe and loop until
# pipe is empty
- data = ro_pipe.readline()
+# data = ro_pipe.readline()
seenlines = 0
+ last_percent = 0
+
+ while 1:
+ data = ro_pipe.read(2048)
+ if not data: break
- while data:
if logfile:
fd_logfile.write(data)
# fd_logfile.flush()
if display_on_tty8:
fd_tty.write(data)
-# fd_tty.flush()
+ fd_tty.flush()
if return_output:
- output = output + data
+ output += data
if linecount and cc:
- seenlines += 1
- if not seenlines % 20:
- cc.addNotification("progress", (float(seenlines) / linecount, status_message))
-
- data = ro_pipe.readline()
+ lastpos = -1
+ while 1:
+ lastpos = data.find("\n", lastpos + 1)
+ if lastpos == -1: break
+ seenlines += 1
+ percent = float(seenlines) / linecount
+ if int(percent * 100) > last_percent:
+ last_percent = int(percent * 100)
+ cc.addNotification("progress", (percent, status_message))
+
+# data = ro_pipe.readline()
# close the file descriptors
if logfile: fd_logfile.close()