OLD | NEW |
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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 "adis": "AccountDisabled", | 390 "adis": "AccountDisabled", |
391 "sdis": "ServiceDisabled", | 391 "sdis": "ServiceDisabled", |
392 "ire": "ServiceUnavailable", | 392 "ire": "ServiceUnavailable", |
393 } | 393 } |
394 auth_token = self._GetAuthToken(credentials[0], credentials[1], | 394 auth_token = self._GetAuthToken(credentials[0], credentials[1], |
395 internal=True) | 395 internal=True) |
396 except ClientLoginError, exc: | 396 except ClientLoginError, exc: |
397 e = exc | 397 e = exc |
398 if e: | 398 if e: |
399 print >> sys.stderr, '' | 399 print >> sys.stderr, '' |
| 400 error_message = e.reason |
400 if error_map: | 401 if error_map: |
401 e.reason = error_map.get(e.reason, e.reason) | 402 error_message = error_map.get(error_message, error_message) |
402 if e.reason == "BadAuthentication": | 403 if error_message == "BadAuthentication": |
403 if e.info == "InvalidSecondFactor": | 404 if e.info == "InvalidSecondFactor": |
404 print >> sys.stderr, ( | 405 print >> sys.stderr, ( |
405 "Use an application-specific password instead " | 406 "Use an application-specific password instead " |
406 "of your regular account password.\n" | 407 "of your regular account password.\n" |
407 "See http://www.google.com/" | 408 "See http://www.google.com/" |
408 "support/accounts/bin/answer.py?answer=185833") | 409 "support/accounts/bin/answer.py?answer=185833") |
409 else: | 410 else: |
410 print >> sys.stderr, "Invalid username or password." | 411 print >> sys.stderr, "Invalid username or password." |
411 elif e.reason == "CaptchaRequired": | 412 elif error_message == "CaptchaRequired": |
412 print >> sys.stderr, ( | 413 print >> sys.stderr, ( |
413 "Please go to\n" | 414 "Please go to\n" |
414 "https://www.google.com/accounts/DisplayUnlockCaptcha\n" | 415 "https://www.google.com/accounts/DisplayUnlockCaptcha\n" |
415 "and verify you are a human. Then try again.\n" | 416 "and verify you are a human. Then try again.\n" |
416 "If you are using a Google Apps account the URL is:\n" | 417 "If you are using a Google Apps account the URL is:\n" |
417 "https://www.google.com/a/yourdomain.com/UnlockCaptcha") | 418 "https://www.google.com/a/yourdomain.com/UnlockCaptcha") |
418 elif e.reason == "NotVerified": | 419 elif error_message == "NotVerified": |
419 print >> sys.stderr, "Account not verified." | 420 print >> sys.stderr, "Account not verified." |
420 elif e.reason == "TermsNotAgreed": | 421 elif error_message == "TermsNotAgreed": |
421 print >> sys.stderr, "User has not agreed to TOS." | 422 print >> sys.stderr, "User has not agreed to TOS." |
422 elif e.reason == "AccountDeleted": | 423 elif error_message == "AccountDeleted": |
423 print >> sys.stderr, "The user account has been deleted." | 424 print >> sys.stderr, "The user account has been deleted." |
424 elif e.reason == "AccountDisabled": | 425 elif error_message == "AccountDisabled": |
425 print >> sys.stderr, "The user account has been disabled." | 426 print >> sys.stderr, "The user account has been disabled." |
426 break | 427 break |
427 elif e.reason == "ServiceDisabled": | 428 elif error_message == "ServiceDisabled": |
428 print >> sys.stderr, ("The user's access to the service has been " | 429 print >> sys.stderr, ("The user's access to the service has been " |
429 "disabled.") | 430 "disabled.") |
430 elif e.reason == "ServiceUnavailable": | 431 elif error_message == "ServiceUnavailable": |
431 print >> sys.stderr, "The service is not available; try again later." | 432 print >> sys.stderr, "The service is not available; try again later." |
432 else: | 433 else: |
433 # Unknown error. | 434 # Unknown error. |
434 raise e | 435 raise e |
435 print >> sys.stderr, '' | 436 print >> sys.stderr, '' |
436 continue | 437 continue |
437 self._GetAuthCookie(auth_token) | 438 self._GetAuthCookie(auth_token) |
438 return | 439 return |
439 | 440 |
440 def Send(self, request_path, payload=None, | 441 def Send(self, request_path, payload=None, |
(...skipping 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 os.environ['LC_ALL'] = 'C' | 2744 os.environ['LC_ALL'] = 'C' |
2744 RealMain(sys.argv) | 2745 RealMain(sys.argv) |
2745 except KeyboardInterrupt: | 2746 except KeyboardInterrupt: |
2746 print | 2747 print |
2747 StatusUpdate("Interrupted.") | 2748 StatusUpdate("Interrupted.") |
2748 sys.exit(1) | 2749 sys.exit(1) |
2749 | 2750 |
2750 | 2751 |
2751 if __name__ == "__main__": | 2752 if __name__ == "__main__": |
2752 main() | 2753 main() |
OLD | NEW |