Chromium Code Reviews| 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 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1552 if options.verbose >= 2: | 1552 if options.verbose >= 2: |
| 1553 logging.basicConfig(level=logging.DEBUG) | 1553 logging.basicConfig(level=logging.DEBUG) |
| 1554 elif options.verbose: | 1554 elif options.verbose: |
| 1555 logging.basicConfig(level=logging.INFO) | 1555 logging.basicConfig(level=logging.INFO) |
| 1556 else: | 1556 else: |
| 1557 logging.basicConfig(level=logging.ERROR) | 1557 logging.basicConfig(level=logging.ERROR) |
| 1558 | 1558 |
| 1559 if options.rietveld_email and options.rietveld_email_file: | 1559 if options.rietveld_email and options.rietveld_email_file: |
| 1560 parser.error("Only one of --rietveld_email or --rietveld_email_file " | 1560 parser.error("Only one of --rietveld_email or --rietveld_email_file " |
| 1561 "can be passed to this program.") | 1561 "can be passed to this program.") |
| 1562 if options.rietveld_private_key_file and options.rietveld_password: | 1562 if options.rietveld_private_key_file: |
| 1563 parser.error("Only one of --rietveld_private_key_file or " | 1563 if options.rietveld_password: |
| 1564 "--rietveld_password can be passed to this program.") | 1564 parser.error("Only one of --rietveld_private_key_file or " |
| 1565 "--rietveld_password can be passed to this program.") | |
| 1566 elif not options.rietveld_password: | |
|
nodir
2014/04/15 03:16:47
I would be more explicit:
options.rietveld_passw
| |
| 1567 # Default to empty password if neither e-mail nor password is supplied | |
| 1568 options.rietveld_password = '' | |
| 1569 | |
| 1565 if options.rietveld_email_file: | 1570 if options.rietveld_email_file: |
| 1566 with open(options.rietveld_email_file, "rb") as f: | 1571 with open(options.rietveld_email_file, "rb") as f: |
| 1567 options.rietveld_email = f.read().strip() | 1572 options.rietveld_email = f.read().strip() |
| 1568 | 1573 |
| 1569 change_class, files = load_files(options, args) | 1574 change_class, files = load_files(options, args) |
| 1570 if not change_class: | 1575 if not change_class: |
| 1571 parser.error('For unversioned directory, <files> is not optional.') | 1576 parser.error('For unversioned directory, <files> is not optional.') |
| 1572 logging.info('Found %d file(s).' % len(files)) | 1577 logging.info('Found %d file(s).' % len(files)) |
| 1573 | 1578 |
| 1574 rietveld_obj = None | 1579 rietveld_obj = None |
| 1575 if options.rietveld_url: | 1580 if options.rietveld_url: |
| 1576 # The empty password is permitted: '' is not None. | 1581 # The empty password is permitted: '' is not None. |
| 1577 if options.rietveld_password is not None: | 1582 if options.rietveld_password is not None: |
| 1578 rietveld_obj = rietveld.CachingRietveld( | 1583 rietveld_obj = rietveld.CachingRietveld( |
| 1579 options.rietveld_url, | 1584 options.rietveld_url, |
| 1580 options.rietveld_email, | 1585 options.rietveld_email, |
| 1581 options.rietveld_password) | 1586 options.rietveld_password) |
| 1582 elif options.rietveld_private_key_file: | 1587 elif options.rietveld_private_key_file: |
|
ghost stip (do not use)
2014/04/15 03:21:39
suggestion: we could do this if check first and if
| |
| 1583 rietveld_obj = rietveld.JwtOAuth2Rietveld( | 1588 rietveld_obj = rietveld.JwtOAuth2Rietveld( |
| 1584 options.rietveld_url, | 1589 options.rietveld_url, |
| 1585 options.rietveld_email, | 1590 options.rietveld_email, |
| 1586 options.rietveld_private_key_file) | 1591 options.rietveld_private_key_file) |
| 1587 else: | 1592 else: |
| 1588 parser.error("No password or secret key has been provided for " | 1593 parser.error("No password or secret key has been provided for " |
| 1589 "Rietveld. Unable to connect.") | 1594 "Rietveld. Unable to connect.") |
| 1590 if options.rietveld_fetch: | 1595 if options.rietveld_fetch: |
| 1591 assert options.issue | 1596 assert options.issue |
| 1592 props = rietveld_obj.get_issue_properties(options.issue, False) | 1597 props = rietveld_obj.get_issue_properties(options.issue, False) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1644 except PresubmitFailure, e: | 1649 except PresubmitFailure, e: |
| 1645 print >> sys.stderr, e | 1650 print >> sys.stderr, e |
| 1646 print >> sys.stderr, 'Maybe your depot_tools is out of date?' | 1651 print >> sys.stderr, 'Maybe your depot_tools is out of date?' |
| 1647 print >> sys.stderr, 'If all fails, contact maruel@' | 1652 print >> sys.stderr, 'If all fails, contact maruel@' |
| 1648 return 2 | 1653 return 2 |
| 1649 | 1654 |
| 1650 | 1655 |
| 1651 if __name__ == '__main__': | 1656 if __name__ == '__main__': |
| 1652 fix_encoding.fix_encoding() | 1657 fix_encoding.fix_encoding() |
| 1653 sys.exit(Main(None)) | 1658 sys.exit(Main(None)) |
| OLD | NEW |