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

Side by Side Diff: apply_issue.py

Issue 20634003: Add anonymous-only option to apply_issue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: use --no-auth Created 7 years, 5 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
« no previous file with comments | « no previous file | rietveld.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 """Applies an issue from Rietveld. 6 """Applies an issue from Rietveld.
7 """ 7 """
8 8
9 import getpass 9 import getpass
10 import logging 10 import logging
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 parser.add_option( 58 parser.add_option(
59 '-r', 59 '-r',
60 '--root_dir', 60 '--root_dir',
61 default=os.getcwd(), 61 default=os.getcwd(),
62 help='Root directory to apply the patch') 62 help='Root directory to apply the patch')
63 parser.add_option( 63 parser.add_option(
64 '-s', 64 '-s',
65 '--server', 65 '--server',
66 default='http://codereview.chromium.org', 66 default='http://codereview.chromium.org',
67 help='Rietveld server') 67 help='Rietveld server')
68 parser.add_option('--no-auth', action='store_true',
69 help='Do not attempt authenticated requests.')
68 options, args = parser.parse_args() 70 options, args = parser.parse_args()
69 logging.basicConfig( 71 logging.basicConfig(
70 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', 72 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s',
71 level=[logging.WARNING, logging.INFO, logging.DEBUG][ 73 level=[logging.WARNING, logging.INFO, logging.DEBUG][
72 min(2, options.verbose)]) 74 min(2, options.verbose)])
73 if args: 75 if args:
74 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) 76 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args))
75 if not options.issue: 77 if not options.issue:
76 parser.error('Require --issue') 78 parser.error('Require --issue')
77 options.server = options.server.rstrip('/') 79 options.server = options.server.rstrip('/')
(...skipping 11 matching lines...) Expand all
89 # Bad except clauses order (HTTPError is an ancestor class of 91 # Bad except clauses order (HTTPError is an ancestor class of
90 # ClientLoginError) 92 # ClientLoginError)
91 # pylint: disable=E0701 93 # pylint: disable=E0701
92 obj = rietveld.Rietveld(options.server, '', None) 94 obj = rietveld.Rietveld(options.server, '', None)
93 properties = None 95 properties = None
94 try: 96 try:
95 properties = obj.get_issue_properties(options.issue, False) 97 properties = obj.get_issue_properties(options.issue, False)
96 except urllib2.HTTPError, e: 98 except urllib2.HTTPError, e:
97 if e.getcode() != 302: 99 if e.getcode() != 302:
98 raise 100 raise
101 elif options.no_auth:
102 exit('FAIL: Login detected -- is issue private?')
99 # TODO(maruel): A few 'Invalid username or password.' are printed first, we 103 # TODO(maruel): A few 'Invalid username or password.' are printed first, we
100 # should get rid of those. 104 # should get rid of those.
101 except rietveld.upload.ClientLoginError, e: 105 except rietveld.upload.ClientLoginError, e:
102 # Fine, we'll do proper authentication. 106 # Fine, we'll do proper authentication.
103 pass 107 pass
104 if properties is None: 108 if properties is None:
105 if options.email is not None: 109 if options.email is not None:
106 obj = rietveld.Rietveld(options.server, options.email, options.password) 110 obj = rietveld.Rietveld(options.server, options.email, options.password)
107 try: 111 try:
108 properties = obj.get_issue_properties(options.issue, False) 112 properties = obj.get_issue_properties(options.issue, False)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 '--nohooks', 185 '--nohooks',
182 '--delete_unversioned_trees', 186 '--delete_unversioned_trees',
183 ], 187 ],
184 cwd=gclient_root) 188 cwd=gclient_root)
185 return 0 189 return 0
186 190
187 191
188 if __name__ == "__main__": 192 if __name__ == "__main__":
189 fix_encoding.fix_encoding() 193 fix_encoding.fix_encoding()
190 sys.exit(main()) 194 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | rietveld.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698