summaryrefslogtreecommitdiff
path: root/Tools/gtk/common.py
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-09-20 21:53:03 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2012-09-20 21:53:03 +0200
commit171053e5e2efcdc6854d8b3a0d06934fb309e53d (patch)
treec85f2b00cea9c5b648ad9945be3155d29d96395f /Tools/gtk/common.py
parent0b3dc81d9701aea106543b49bde511a5697cdd6e (diff)
downloadqtwebkit-171053e5e2efcdc6854d8b3a0d06934fb309e53d.tar.gz
Imported WebKit commit f35955d976484e57fd83612794aefd58fdaa6337 (http://svn.webkit.org/repository/webkit/trunk@129155)
New snapshot with prospective build fix
Diffstat (limited to 'Tools/gtk/common.py')
-rw-r--r--Tools/gtk/common.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Tools/gtk/common.py b/Tools/gtk/common.py
index 7b057e7d1..e090efc6a 100644
--- a/Tools/gtk/common.py
+++ b/Tools/gtk/common.py
@@ -15,7 +15,9 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import errno
import os
+import select
import subprocess
import sys
@@ -102,3 +104,32 @@ def gtk_version_of_pkg_config_file(pkg_config_path):
if 'gtk+-3.0' in stdout:
return 3
return 2
+
+
+def parse_output_lines(fd, parse_line_callback):
+ output = ''
+ read_set = [fd]
+ while read_set:
+ rlist, wlist, xlist = select.select(read_set, [], [])
+
+ if fd in rlist:
+ try:
+ chunk = os.read(fd, 1024)
+ except OSError as e:
+ if e.errno == errno.EIO:
+ # Child process finished.
+ chunk = ''
+ else:
+ raise e
+ if not chunk:
+ read_set.remove(fd)
+
+ output += chunk
+ while '\n' in output:
+ pos = output.find('\n')
+ parse_line_callback(output[:pos + 1])
+ output = output[pos + 1:]
+
+ if len(chunk) < 1024 and output:
+ parse_line_callback(output)
+ output = ''