| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Snapshot Build Bisect Tool | 6 """Snapshot Build Bisect Tool |
| 7 | 7 |
| 8 This script bisects a snapshot archive using binary search. It starts at | 8 This script bisects a snapshot archive using binary search. It starts at |
| 9 a bad revision (it will try to guess HEAD) and asks for a last known-good | 9 a bad revision (it will try to guess HEAD) and asks for a last known-good |
| 10 revision. It will then binary search across this revision range by downloading, | 10 revision. It will then binary search across this revision range by downloading, |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 @param context A PathContext instance. | 204 @param context A PathContext instance. |
| 205 @param rev The Chromium revision number/tag to download. | 205 @param rev The Chromium revision number/tag to download. |
| 206 @param filename The destination for the downloaded file. | 206 @param filename The destination for the downloaded file. |
| 207 @param quit_event A threading.Event which will be set by the master thread to | 207 @param quit_event A threading.Event which will be set by the master thread to |
| 208 indicate that the download should be aborted. | 208 indicate that the download should be aborted. |
| 209 @param progress_event A threading.Event which will be set by the master thread | 209 @param progress_event A threading.Event which will be set by the master thread |
| 210 to indicate that the progress of the download should be | 210 to indicate that the progress of the download should be |
| 211 displayed. | 211 displayed. |
| 212 """ | 212 """ |
| 213 def ReportHook(blocknum, blocksize, totalsize): | 213 def ReportHook(blocknum, blocksize, totalsize): |
| 214 if quit_event and quit_event.is_set(): | 214 if quit_event and quit_event.isSet(): |
| 215 raise RuntimeError("Aborting download of revision %d" % rev) | 215 raise RuntimeError("Aborting download of revision %d" % rev) |
| 216 if progress_event and progress_event.is_set(): | 216 if progress_event and progress_event.isSet(): |
| 217 size = blocknum * blocksize | 217 size = blocknum * blocksize |
| 218 if totalsize == -1: # Total size not known. | 218 if totalsize == -1: # Total size not known. |
| 219 progress = "Received %d bytes" % size | 219 progress = "Received %d bytes" % size |
| 220 else: | 220 else: |
| 221 size = min(totalsize, size) | 221 size = min(totalsize, size) |
| 222 progress = "Received %d of %d bytes, %.2f%%" % ( | 222 progress = "Received %d of %d bytes, %.2f%%" % ( |
| 223 size, totalsize, 100.0 * size / totalsize) | 223 size, totalsize, 100.0 * size / totalsize) |
| 224 # Send a \r to let all progress messages use just one line of output. | 224 # Send a \r to let all progress messages use just one line of output. |
| 225 sys.stdout.write("\r" + progress) | 225 sys.stdout.write("\r" + progress) |
| 226 sys.stdout.flush() | 226 sys.stdout.flush() |
| 227 | 227 |
| 228 download_url = context.GetDownloadURL(rev) | 228 download_url = context.GetDownloadURL(rev) |
| 229 try: | 229 try: |
| 230 urllib.urlretrieve(download_url, filename, ReportHook) | 230 urllib.urlretrieve(download_url, filename, ReportHook) |
| 231 if progress_event and progress_event.is_set(): | 231 if progress_event and progress_event.isSet(): |
| 232 print() | 232 print() |
| 233 except RuntimeError, e: | 233 except RuntimeError, e: |
| 234 pass | 234 pass |
| 235 | 235 |
| 236 | 236 |
| 237 def RunRevision(context, revision, zipfile, profile, args): | 237 def RunRevision(context, revision, zipfile, profile, args): |
| 238 """Given a zipped revision, unzip it and run the test.""" | 238 """Given a zipped revision, unzip it and run the test.""" |
| 239 print "Trying revision %d..." % revision | 239 print "Trying revision %d..." % revision |
| 240 | 240 |
| 241 # Create a temp directory and unzip the revision into it. | 241 # Create a temp directory and unzip the revision into it. |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 494 |
| 495 # We're done. Let the user know the results in an official manner. | 495 # We're done. Let the user know the results in an official manner. |
| 496 print('You are probably looking for build %d.' % first_known_bad_rev) | 496 print('You are probably looking for build %d.' % first_known_bad_rev) |
| 497 print('CHANGELOG URL:') | 497 print('CHANGELOG URL:') |
| 498 print(CHANGELOG_URL % (last_known_good_rev, first_known_bad_rev)) | 498 print(CHANGELOG_URL % (last_known_good_rev, first_known_bad_rev)) |
| 499 print('Built at revision:') | 499 print('Built at revision:') |
| 500 print(BUILD_VIEWVC_URL % first_known_bad_rev) | 500 print(BUILD_VIEWVC_URL % first_known_bad_rev) |
| 501 | 501 |
| 502 if __name__ == '__main__': | 502 if __name__ == '__main__': |
| 503 sys.exit(main()) | 503 sys.exit(main()) |
| OLD | NEW |