| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 __version__ = '1.8.0' | 9 __version__ = '1.8.0' |
| 10 | 10 |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 duration = time.time() - start | 1524 duration = time.time() - start |
| 1525 return cmd_data.message( | 1525 return cmd_data.message( |
| 1526 '%s exec failure (%4.2fs)\n %s' % (cmd_data.name, duration, e)) | 1526 '%s exec failure (%4.2fs)\n %s' % (cmd_data.name, duration, e)) |
| 1527 if code != 0: | 1527 if code != 0: |
| 1528 return cmd_data.message( | 1528 return cmd_data.message( |
| 1529 '%s (%4.2fs) failed\n%s' % (cmd_data.name, duration, out)) | 1529 '%s (%4.2fs) failed\n%s' % (cmd_data.name, duration, out)) |
| 1530 if cmd_data.info: | 1530 if cmd_data.info: |
| 1531 return cmd_data.info('%s (%4.2fs)' % (cmd_data.name, duration)) | 1531 return cmd_data.info('%s (%4.2fs)' % (cmd_data.name, duration)) |
| 1532 | 1532 |
| 1533 | 1533 |
| 1534 def Main(argv): | 1534 def main(argv=None): |
| 1535 parser = optparse.OptionParser(usage="%prog [options] <files...>", | 1535 parser = optparse.OptionParser(usage="%prog [options] <files...>", |
| 1536 version="%prog " + str(__version__)) | 1536 version="%prog " + str(__version__)) |
| 1537 parser.add_option("-c", "--commit", action="store_true", default=False, | 1537 parser.add_option("-c", "--commit", action="store_true", default=False, |
| 1538 help="Use commit instead of upload checks") | 1538 help="Use commit instead of upload checks") |
| 1539 parser.add_option("-u", "--upload", action="store_false", dest='commit', | 1539 parser.add_option("-u", "--upload", action="store_false", dest='commit', |
| 1540 help="Use upload instead of commit checks") | 1540 help="Use upload instead of commit checks") |
| 1541 parser.add_option("-r", "--recursive", action="store_true", | 1541 parser.add_option("-r", "--recursive", action="store_true", |
| 1542 help="Act recursively") | 1542 help="Act recursively") |
| 1543 parser.add_option("-v", "--verbose", action="count", default=0, | 1543 parser.add_option("-v", "--verbose", action="count", default=0, |
| 1544 help="Use 2 times for more debug info") | 1544 help="Use 2 times for more debug info") |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 return 2 | 1668 return 2 |
| 1669 except PresubmitFailure, e: | 1669 except PresubmitFailure, e: |
| 1670 print >> sys.stderr, e | 1670 print >> sys.stderr, e |
| 1671 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1671 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
| 1672 print >> sys.stderr, 'If all fails, contact maruel@' | 1672 print >> sys.stderr, 'If all fails, contact maruel@' |
| 1673 return 2 | 1673 return 2 |
| 1674 | 1674 |
| 1675 | 1675 |
| 1676 if __name__ == '__main__': | 1676 if __name__ == '__main__': |
| 1677 fix_encoding.fix_encoding() | 1677 fix_encoding.fix_encoding() |
| 1678 sys.exit(Main(None)) | 1678 try: |
| 1679 sys.exit(main()) |
| 1680 except KeyboardInterrupt: |
| 1681 sys.stderr.write('interrupted\n') |
| 1682 sys.exit(1) |
| OLD | NEW |