diff options
author | Kristian Monsen <kristianm@google.com> | 2010-09-30 15:42:16 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-10-07 10:59:29 +0100 |
commit | bec39347bb3bb5bf1187ccaf471d26247f28b585 (patch) | |
tree | 56bdc4c2978fbfd3d79d0d36d5d6c640ecc09cc8 /WebKitTools/Scripts/webkitpy/common/net/credentials.py | |
parent | 90b7966e7815b262cd19ac25f03aaad9b21fdc06 (diff) | |
download | external_webkit-bec39347bb3bb5bf1187ccaf471d26247f28b585.zip external_webkit-bec39347bb3bb5bf1187ccaf471d26247f28b585.tar.gz external_webkit-bec39347bb3bb5bf1187ccaf471d26247f28b585.tar.bz2 |
Merge WebKit at r68651 : Initial merge by git.
Change-Id: I3d6bff59f17eedd6722723354f386fec9be8ad12
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/common/net/credentials.py')
-rw-r--r-- | WebKitTools/Scripts/webkitpy/common/net/credentials.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/WebKitTools/Scripts/webkitpy/common/net/credentials.py b/WebKitTools/Scripts/webkitpy/common/net/credentials.py index 1d5f83d..1c3e6c0 100644 --- a/WebKitTools/Scripts/webkitpy/common/net/credentials.py +++ b/WebKitTools/Scripts/webkitpy/common/net/credentials.py @@ -39,14 +39,23 @@ from webkitpy.common.system.executive import Executive, ScriptError from webkitpy.common.system.user import User from webkitpy.common.system.deprecated_logging import log +try: + # Use keyring, a cross platform keyring interface, as a fallback: + # http://pypi.python.org/pypi/keyring + import keyring +except ImportError: + keyring = None + class Credentials(object): - def __init__(self, host, git_prefix=None, executive=None, cwd=os.getcwd()): + def __init__(self, host, git_prefix=None, executive=None, cwd=os.getcwd(), + keyring=keyring): self.host = host self.git_prefix = "%s." % git_prefix if git_prefix else "" self.executive = executive or Executive() self.cwd = cwd + self._keyring = keyring def _credentials_from_git(self): return [Git.read_git_config(self.git_prefix + "username"), @@ -117,10 +126,19 @@ class Credentials(object): if not username or not password: (username, password) = self._credentials_from_keychain(username) + if username and not password and self._keyring: + password = self._keyring.get_password(self.host, username) + if not username: username = User.prompt("%s login: " % self.host) if not password: password = getpass.getpass("%s password for %s: " % (self.host, username)) + if self._keyring: + store_password = User().confirm( + "Store password in system keyring?", User.DEFAULT_NO) + if store_password: + self._keyring.set_password(self.host, username, password) + return [username, password] |