Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2007 Google Inc. | 3 # Copyright 2007 Google Inc. |
| 4 # | 4 # |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
| 7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
| 8 # | 8 # |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 # | 10 # |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 605 save_cookies=save_cookies, | 605 save_cookies=save_cookies, |
| 606 account_type=account_type) | 606 account_type=account_type) |
| 607 # Don't try to talk to ClientLogin. | 607 # Don't try to talk to ClientLogin. |
| 608 server.authenticated = True | 608 server.authenticated = True |
| 609 return server | 609 return server |
| 610 | 610 |
| 611 def GetUserCredentials(): | 611 def GetUserCredentials(): |
| 612 """Prompts the user for a username and password.""" | 612 """Prompts the user for a username and password.""" |
| 613 # Create a local alias to the email variable to avoid Python's crazy | 613 # Create a local alias to the email variable to avoid Python's crazy |
| 614 # scoping rules. | 614 # scoping rules. |
| 615 global keyring | |
| 615 local_email = email | 616 local_email = email |
| 616 if local_email is None: | 617 if local_email is None: |
| 617 local_email = GetEmail("Email (login for uploading to %s)" % server) | 618 local_email = GetEmail("Email (login for uploading to %s)" % server) |
| 618 password = None | 619 password = None |
| 619 if keyring: | 620 if keyring: |
| 620 password = keyring.get_password(host, local_email) | 621 try: |
| 622 password = keyring.get_password(host, local_email) | |
| 623 except: | |
| 624 # Sadly, we have to trap all errors here as | |
| 625 # gnomekeyring.IOError inherits from object. :/ | |
|
Dirk Pranke
2011/08/23 20:13:27
I don't get this; you're saying that you can't che
M-A Ruel
2011/08/23 20:14:36
No, that the keyring module is a leaky abstraction
| |
| 626 print "Failed to get password from keyring" | |
| 627 keyring = None | |
| 621 if password is not None: | 628 if password is not None: |
| 622 print "Using password from system keyring." | 629 print "Using password from system keyring." |
| 623 else: | 630 else: |
| 624 password = getpass.getpass("Password for %s: " % local_email) | 631 password = getpass.getpass("Password for %s: " % local_email) |
| 625 if keyring: | 632 if keyring: |
| 626 answer = raw_input("Store password in system keyring?(y/N) ").strip() | 633 answer = raw_input("Store password in system keyring?(y/N) ").strip() |
| 627 if answer == "y": | 634 if answer == "y": |
| 628 keyring.set_password(host, local_email, password) | 635 keyring.set_password(host, local_email, password) |
| 629 return (local_email, password) | 636 return (local_email, password) |
| 630 | 637 |
| (...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2249 os.environ['LC_ALL'] = 'C' | 2256 os.environ['LC_ALL'] = 'C' |
| 2250 RealMain(sys.argv) | 2257 RealMain(sys.argv) |
| 2251 except KeyboardInterrupt: | 2258 except KeyboardInterrupt: |
| 2252 print | 2259 print |
| 2253 StatusUpdate("Interrupted.") | 2260 StatusUpdate("Interrupted.") |
| 2254 sys.exit(1) | 2261 sys.exit(1) |
| 2255 | 2262 |
| 2256 | 2263 |
| 2257 if __name__ == "__main__": | 2264 if __name__ == "__main__": |
| 2258 main() | 2265 main() |
| OLD | NEW |