Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Side by Side Diff: presubmit_support.py

Issue 955993006: Handle KeyboardInterrupt consistently in python scripts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: tweek test expectations Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« clang_format.py ('K') | « my_reviews.py ('k') | pylint.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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)
OLDNEW
« clang_format.py ('K') | « my_reviews.py ('k') | pylint.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698