本文整理汇总了Python中webkitpy.common.net.credentials.Credentials.read_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python Credentials.read_credentials方法的具体用法?Python Credentials.read_credentials怎么用?Python Credentials.read_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webkitpy.common.net.credentials.Credentials
的用法示例。
在下文中一共展示了Credentials.read_credentials方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authenticate
# 需要导入模块: from webkitpy.common.net.credentials import Credentials [as 别名]
# 或者: from webkitpy.common.net.credentials.Credentials import read_credentials [as 别名]
def authenticate(self):
if self.authenticated:
return
credentials = Credentials(config_urls.bug_server_host, git_prefix="bugzilla")
attempts = 0
while not self.authenticated:
attempts += 1
username, password = credentials.read_credentials()
_log.info("Logging in as %s..." % username)
self.browser.open(config_urls.bug_server_url +
"index.cgi?GoAheadAndLogIn=1")
self.browser.select_form(name="login")
self.browser['Bugzilla_login'] = username
self.browser['Bugzilla_password'] = password
self.browser.find_control("Bugzilla_restrictlogin").items[0].selected = False
response = self.browser.submit()
match = re.search("<title>(.+?)</title>", response.read())
# If the resulting page has a title, and it contains the word
# "invalid" assume it's the login failure page.
if match and re.search("Invalid", match.group(1), re.IGNORECASE):
errorMessage = "Bugzilla login failed: %s" % match.group(1)
# raise an exception only if this was the last attempt
if attempts < 5:
_log.error(errorMessage)
else:
raise Exception(errorMessage)
else:
self.authenticated = True
self.username = username