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

Side by Side Diff: third_party/upload.py

Issue 1060633003: upload.py: Fix undefined variable bug. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 8 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 | no next file » | 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 # coding: utf-8 2 # coding: utf-8
3 # 3 #
4 # Copyright 2007 Google Inc. 4 # Copyright 2007 Google Inc.
5 # 5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License. 7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at 8 # You may obtain a copy of the License at
9 # 9 #
10 # http://www.apache.org/licenses/LICENSE-2.0 10 # http://www.apache.org/licenses/LICENSE-2.0
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 2) We use ClientLogin to obtain an AUTH token for the user 365 2) We use ClientLogin to obtain an AUTH token for the user
366 (see http://code.google.com/apis/accounts/AuthForInstalledApps.html). 366 (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).
367 3) We pass the auth token to /_ah/login on the server to obtain an 367 3) We pass the auth token to /_ah/login on the server to obtain an
368 authentication cookie. If login was successful, it tries to redirect 368 authentication cookie. If login was successful, it tries to redirect
369 us to the URL we provided. 369 us to the URL we provided.
370 370
371 If we attempt to access the upload API without first obtaining an 371 If we attempt to access the upload API without first obtaining an
372 authentication cookie, it returns a 401 response (or a 302) and 372 authentication cookie, it returns a 401 response (or a 302) and
373 directs us to authenticate ourselves with ClientLogin. 373 directs us to authenticate ourselves with ClientLogin.
374 """ 374 """
375 INTERNAL_ERROR_MAP = {
376 "badauth": "BadAuthentication",
377 "cr": "CaptchaRequired",
378 "adel": "AccountDeleted",
379 "adis": "AccountDisabled",
380 "sdis": "ServiceDisabled",
381 "ire": "ServiceUnavailable",
382 }
383
384 for i in range(3): 375 for i in range(3):
385 credentials = self.auth_function() 376 credentials = self.auth_function()
386 377
387 # Try external, then internal. 378 # Try external, then internal.
388 e = None 379 e = None
380 error_map = None
389 try: 381 try:
390 auth_token = self._GetAuthToken(credentials[0], credentials[1]) 382 auth_token = self._GetAuthToken(credentials[0], credentials[1])
391 except urllib2.HTTPError: 383 except urllib2.HTTPError:
392 try: 384 try:
385 # Try internal endpoint.
386 error_map = {
387 "badauth": "BadAuthentication",
388 "cr": "CaptchaRequired",
389 "adel": "AccountDeleted",
390 "adis": "AccountDisabled",
391 "sdis": "ServiceDisabled",
392 "ire": "ServiceUnavailable",
393 }
393 auth_token = self._GetAuthToken(credentials[0], credentials[1], 394 auth_token = self._GetAuthToken(credentials[0], credentials[1],
394 internal=True) 395 internal=True)
395 except ClientLoginError, exc: 396 except ClientLoginError, exc:
396 e = exc 397 e = exc
397 if e: 398 if e:
398 print >> sys.stderr, '' 399 print >> sys.stderr, ''
399 if internal: 400 if error_map:
400 e.reason = INTERNAL_ERROR_MAP.get(e.reason, e.reason) 401 e.reason = error_map.get(e.reason, e.reason)
401 if e.reason == "BadAuthentication": 402 if e.reason == "BadAuthentication":
402 if e.info == "InvalidSecondFactor": 403 if e.info == "InvalidSecondFactor":
403 print >> sys.stderr, ( 404 print >> sys.stderr, (
404 "Use an application-specific password instead " 405 "Use an application-specific password instead "
405 "of your regular account password.\n" 406 "of your regular account password.\n"
406 "See http://www.google.com/" 407 "See http://www.google.com/"
407 "support/accounts/bin/answer.py?answer=185833") 408 "support/accounts/bin/answer.py?answer=185833")
408 else: 409 else:
409 print >> sys.stderr, "Invalid username or password." 410 print >> sys.stderr, "Invalid username or password."
410 elif e.reason == "CaptchaRequired": 411 elif e.reason == "CaptchaRequired":
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2742 os.environ['LC_ALL'] = 'C' 2743 os.environ['LC_ALL'] = 'C'
2743 RealMain(sys.argv) 2744 RealMain(sys.argv)
2744 except KeyboardInterrupt: 2745 except KeyboardInterrupt:
2745 print 2746 print
2746 StatusUpdate("Interrupted.") 2747 StatusUpdate("Interrupted.")
2747 sys.exit(1) 2748 sys.exit(1)
2748 2749
2749 2750
2750 if __name__ == "__main__": 2751 if __name__ == "__main__":
2751 main() 2752 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698