| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/env 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 | 6 |
| 7 """Script to clean the lcov files and convert it to HTML | 7 """Script to clean the lcov files and convert it to HTML |
| 8 | 8 |
| 9 TODO(niranjan): Add usage information here | 9 TODO(niranjan): Add usage information here |
| 10 """ | 10 """ |
| 11 | 11 |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 if num_fails < MAX_FAILURES: | 338 if num_fails < MAX_FAILURES: |
| 339 print 'fail, retrying (%d)' % num_fails | 339 print 'fail, retrying (%d)' % num_fails |
| 340 time.sleep(5) | 340 time.sleep(5) |
| 341 SendPost(req) | 341 SendPost(req) |
| 342 else: | 342 else: |
| 343 print 'POST request exceeded allowed retries.' | 343 print 'POST request exceeded allowed retries.' |
| 344 raise | 344 raise |
| 345 | 345 |
| 346 | 346 |
| 347 def main(): | 347 def main(): |
| 348 if sys.platform[:5] != 'linux': # Run this only on Linux | 348 if not sys.platform.startswith('linux'): |
| 349 print 'This script is supported only on Linux' | 349 print 'This script is supported only on Linux' |
| 350 os.exit(1) | 350 return 0 |
| 351 | 351 |
| 352 # Command line parsing | 352 # Command line parsing |
| 353 parser = optparse.OptionParser() | 353 parser = optparse.OptionParser() |
| 354 parser.add_option('-p', | 354 parser.add_option('-p', |
| 355 '--platform', | 355 '--platform', |
| 356 dest='platform', | 356 dest='platform', |
| 357 default=None, | 357 default=None, |
| 358 help=('Platform that the locv file was generated on. Must' | 358 help=('Platform that the locv file was generated on. Must' |
| 359 'be one of {win32, linux2, linux3, macosx}')) | 359 'be one of {win32, linux2, linux3, macosx}')) |
| 360 parser.add_option('-s', | 360 parser.add_option('-s', |
| (...skipping 27 matching lines...) Expand all Loading... |
| 388 if options.dash_root == None: | 388 if options.dash_root == None: |
| 389 parser.error('Dashboard root not specified') | 389 parser.error('Dashboard root not specified') |
| 390 if options.post_url == None: | 390 if options.post_url == None: |
| 391 parser.error('Post URL not specified') | 391 parser.error('Post URL not specified') |
| 392 if options.platform == 'win32': | 392 if options.platform == 'win32': |
| 393 CleanWin32Lcov(options.lcov_path, options.src_dir) | 393 CleanWin32Lcov(options.lcov_path, options.src_dir) |
| 394 percent = GenerateHtml(options.lcov_path, options.dash_root) | 394 percent = GenerateHtml(options.lcov_path, options.dash_root) |
| 395 if percent == None: | 395 if percent == None: |
| 396 # TODO(niranjan): Add logging. | 396 # TODO(niranjan): Add logging. |
| 397 print 'Failed to generate code coverage' | 397 print 'Failed to generate code coverage' |
| 398 os.exit(1) | 398 return 1 |
| 399 else: | 399 else: |
| 400 # TODO(niranjan): Do something with the code coverage numbers | 400 # TODO(niranjan): Do something with the code coverage numbers |
| 401 pass | 401 pass |
| 402 else: | 402 else: |
| 403 print 'Unsupported platform' | 403 print 'Unsupported platform' |
| 404 os.exit(1) | 404 return 1 |
| 405 | 405 |
| 406 # Prep coverage results for dashboard and post new set. | 406 # Prep coverage results for dashboard and post new set. |
| 407 parsed_data = ParseCoverageDataForDashboard(options.lcov_path) | 407 parsed_data = ParseCoverageDataForDashboard(options.lcov_path) |
| 408 PostResultsToDashboard(options.lcov_path, parsed_data, options.post_url) | 408 PostResultsToDashboard(options.lcov_path, parsed_data, options.post_url) |
| 409 return 0 |
| 409 | 410 |
| 410 | 411 |
| 411 if __name__ == '__main__': | 412 if __name__ == '__main__': |
| 412 main() | 413 sys.exit(main()) |
| OLD | NEW |