OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | 5 import logging |
6 import platform | 6 import platform |
7 import os | 7 import os |
8 import signal | 8 import signal |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 p = subprocess.Popen(proc, universal_newlines=True, | 48 p = subprocess.Popen(proc, universal_newlines=True, |
49 bufsize=0, # unbuffered | 49 bufsize=0, # unbuffered |
50 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 50 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
51 | 51 |
52 logging.info("started subprocess") | 52 logging.info("started subprocess") |
53 | 53 |
54 did_timeout = False | 54 did_timeout = False |
55 if timeout > 0: | 55 if timeout > 0: |
56 wait_until = time.time() + timeout | 56 wait_until = time.time() + timeout |
57 while p.poll() is None and not did_timeout: | 57 while p.poll() is None and not did_timeout: |
| 58 # Have to use readline rather than readlines() or "for line in p.stdout:", |
| 59 # otherwise we get buffered even with bufsize=0. |
58 line = p.stdout.readline() | 60 line = p.stdout.readline() |
59 while line and not did_timeout: | 61 while line and not did_timeout: |
60 sys.stdout.write(line) | 62 sys.stdout.write(line) |
61 sys.stdout.flush() | 63 sys.stdout.flush() |
62 line = p.stdout.readline() | 64 line = p.stdout.readline() |
63 if timeout > 0: | 65 if timeout > 0: |
64 did_timeout = time.time() > wait_until | 66 did_timeout = time.time() > wait_until |
65 | 67 |
66 if did_timeout: | 68 if did_timeout: |
67 logging.info("process timed out") | 69 logging.info("process timed out") |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 return False | 243 return False |
242 | 244 |
243 print "-----------------------------------------------------" | 245 print "-----------------------------------------------------" |
244 print "Suppressions used:" | 246 print "Suppressions used:" |
245 print " count name" | 247 print " count name" |
246 for (name, count) in sorted(suppcounts.items(), key=lambda (k,v): (v,k)): | 248 for (name, count) in sorted(suppcounts.items(), key=lambda (k,v): (v,k)): |
247 print "%7d %s" % (count, name) | 249 print "%7d %s" % (count, name) |
248 print "-----------------------------------------------------" | 250 print "-----------------------------------------------------" |
249 sys.stdout.flush() | 251 sys.stdout.flush() |
250 return True | 252 return True |
OLD | NEW |