Lines Matching full:self
45 def __init__(self, host, git_prefix=None, executive=None, cwd=os.getcwd()):
46 self.host = host
47 self.git_prefix = git_prefix
48 self.executive = executive or Executive()
49 self.cwd = cwd
51 def _credentials_from_git(self):
52 return [self._read_git_config("username"),
53 self._read_git_config("password")]
55 def _read_git_config(self, key):
56 config_key = "%s.%s" % (self.git_prefix, key) if self.git_prefix \
58 return self.executive.run_command(
62 def _keychain_value_with_label(self, label, source_text):
69 def _is_mac_os_x(self):
72 def _parse_security_tool_output(self, security_output):
73 username = self._keychain_value_with_label("^\s*\"acct\"<blob>=",
75 password = self._keychain_value_with_label("^password: ",
79 def _run_security_tool(self, username=None):
85 self.host,
91 "Click \"Allow\" to continue..." % self.host)
93 return self.executive.run_command(security_command)
98 log("Could not find a keychain entry for %s." % self.host)
101 def _credentials_from_keychain(self, username=None):
102 if not self._is_mac_os_x():
105 security_output = self._run_security_tool(username)
107 return self._parse_security_tool_output(security_output)
111 def read_credentials(self):
116 if Git.in_working_directory(self.cwd):
117 (username, password) = self._credentials_from_git()
125 (username, password) = self._credentials_from_keychain(username)
128 username = User.prompt("%s login: " % self.host)
130 password = getpass.getpass("%s password for %s: " % (self.host,