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.6.2' | 9 __version__ = '1.6.2' |
10 | 10 |
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1292 def CallCommand(cmd_data): | 1292 def CallCommand(cmd_data): |
1293 # multiprocessing needs a top level function with a single argument. | 1293 # multiprocessing needs a top level function with a single argument. |
1294 cmd_data.kwargs['stdout'] = subprocess.PIPE | 1294 cmd_data.kwargs['stdout'] = subprocess.PIPE |
1295 cmd_data.kwargs['stderr'] = subprocess.STDOUT | 1295 cmd_data.kwargs['stderr'] = subprocess.STDOUT |
1296 try: | 1296 try: |
1297 (out, _), code = subprocess.communicate(cmd_data.cmd, **cmd_data.kwargs) | 1297 (out, _), code = subprocess.communicate(cmd_data.cmd, **cmd_data.kwargs) |
1298 if code != 0: | 1298 if code != 0: |
1299 return cmd_data.message('%s failed\n%s' % (cmd_data.name, out)) | 1299 return cmd_data.message('%s failed\n%s' % (cmd_data.name, out)) |
1300 except OSError as e: | 1300 except OSError as e: |
1301 return cmd_data.message( | 1301 return cmd_data.message( |
1302 '%s exec failure\n %s\n%s' % (cmd_data.name, e, out)) | 1302 '%s exec failure\n %s' % (cmd_data.name, e)) |
1303 | 1303 |
1304 | 1304 |
1305 def Main(argv): | 1305 def Main(argv): |
1306 parser = optparse.OptionParser(usage="%prog [options] <files...>", | 1306 parser = optparse.OptionParser(usage="%prog [options] <files...>", |
1307 version="%prog " + str(__version__)) | 1307 version="%prog " + str(__version__)) |
1308 parser.add_option("-c", "--commit", action="store_true", default=False, | 1308 parser.add_option("-c", "--commit", action="store_true", default=False, |
1309 help="Use commit instead of upload checks") | 1309 help="Use commit instead of upload checks") |
1310 parser.add_option("-u", "--upload", action="store_false", dest='commit', | 1310 parser.add_option("-u", "--upload", action="store_false", dest='commit', |
1311 help="Use upload instead of commit checks") | 1311 help="Use upload instead of commit checks") |
1312 parser.add_option("-r", "--recursive", action="store_true", | 1312 parser.add_option("-r", "--recursive", action="store_true", |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 except PresubmitFailure, e: | 1383 except PresubmitFailure, e: |
1384 print >> sys.stderr, e | 1384 print >> sys.stderr, e |
1385 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1385 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
1386 print >> sys.stderr, 'If all fails, contact maruel@' | 1386 print >> sys.stderr, 'If all fails, contact maruel@' |
1387 return 2 | 1387 return 2 |
1388 | 1388 |
1389 | 1389 |
1390 if __name__ == '__main__': | 1390 if __name__ == '__main__': |
1391 fix_encoding.fix_encoding() | 1391 fix_encoding.fix_encoding() |
1392 sys.exit(Main(None)) | 1392 sys.exit(Main(None)) |
OLD | NEW |