Chromium Code Reviews| Index: apply_issue.py |
| diff --git a/apply_issue.py b/apply_issue.py |
| index 2b7b334f51eb6f4bd4683341bb07824f2e412c78..625fd4d5d98a9774ccca3cd6cd654ef5989f5baf 100755 |
| --- a/apply_issue.py |
| +++ b/apply_issue.py |
| @@ -18,6 +18,7 @@ import urllib2 |
| import breakpad # pylint: disable=W0611 |
| import annotated_gclient |
| +import auth |
| import checkout |
| import fix_encoding |
| import gclient_utils |
| @@ -56,13 +57,10 @@ def main(): |
| help='File containing the email address to access rietveld. ' |
| 'If not specified, anonymous access will be used.') |
| parser.add_option( |
| - '-w', '--password', |
| - help='Password for email addressed. Use - to read password from stdin. ' |
| - 'if -k is provided, this is the private key file password.') |
| - parser.add_option( |
| '-k', '--private-key-file', |
| help='Path to file containing a private key in p12 format for OAuth2 ' |
| - 'authentication. Use -w to provide the decrypting password, if any.') |
| + 'authentication with "notasecret" password (as generated by Google ' |
| + 'Cloud Console).') |
| parser.add_option( |
| '-i', '--issue', type='int', help='Rietveld issue number') |
| parser.add_option( |
| @@ -92,13 +90,14 @@ def main(): |
| help='Don\'t patch specified file(s).') |
| parser.add_option('-d', '--ignore_deps', action='store_true', |
| help='Don\'t run gclient sync on DEPS changes.') |
| + |
| + auth.add_auth_options(parser) |
| options, args = parser.parse_args() |
| + auth_config = auth.extract_auth_config_from_options(options) |
| if options.whitelist and options.blacklist: |
| parser.error('Cannot specify both --whitelist and --blacklist') |
| - if options.password and options.private_key_file: |
| - parser.error('-k and -w options are incompatible') |
| if options.email and options.email_file: |
| parser.error('-e and -E options are incompatible') |
| @@ -121,10 +120,6 @@ def main(): |
| options.revision_mapping = json.loads(options.revision_mapping) |
| - if options.password == '-': |
| - print('Reading password') |
| - options.password = sys.stdin.readline().strip() |
| - |
| # read email if needed |
| if options.email_file: |
| if not os.path.exists(options.email_file): |
| @@ -138,11 +133,11 @@ def main(): |
| # OAuth2 authentication |
| obj = rietveld.JwtOAuth2Rietveld(options.server, |
| options.email, |
| - options.private_key_file, |
| - private_key_password=options.password) |
| + options.private_key_file) |
| properties = obj.get_issue_properties(options.issue, False) |
| else: |
| - obj = rietveld.Rietveld(options.server, '', None) |
| + # Passing None as auth_config disables authentication. |
| + obj = rietveld.Rietveld(options.server, None) |
| properties = None |
| # Bad except clauses order (HTTPError is an ancestor class of |
| # ClientLoginError) |
| @@ -160,22 +155,12 @@ def main(): |
| # Fine, we'll do proper authentication. |
| pass |
| if properties is None: |
| - if options.email is not None: |
| - obj = rietveld.Rietveld(options.server, options.email, options.password) |
| - try: |
| - properties = obj.get_issue_properties(options.issue, False) |
| - except rietveld.upload.ClientLoginError, e: |
| - if sys.stdout.closed: |
| - print('Accessing the issue requires proper credentials.') |
| - return 1 |
| - else: |
| - print('Accessing the issue requires login.') |
| - obj = rietveld.Rietveld(options.server, None, None) |
| - try: |
| - properties = obj.get_issue_properties(options.issue, False) |
| - except rietveld.upload.ClientLoginError, e: |
| - print('Accessing the issue requires proper credentials.') |
| - return 1 |
| + obj = rietveld.Rietveld(options.server, auth_config, options.email) |
| + try: |
| + properties = obj.get_issue_properties(options.issue, False) |
| + except rietveld.upload.ClientLoginError, e: |
|
M-A Ruel
2015/04/09 01:20:59
except rietveld.upload.ClientLoginError as e:
Vadim Sh.
2015/04/09 01:34:29
Done.
|
| + print('Accessing the issue requires proper credentials.') |
| + return 1 |
| if not options.patchset: |
| options.patchset = properties['patchsets'][-1] |