diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-08-27 11:03:18 +0900 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-08-27 11:07:01 +0900 |
| commit | c87e4bc55eb701b4ceb9fa77d29bc2ba61bb4063 (patch) | |
| tree | 672471d19900c9f12931df88b64e2291d90220cc /pygerrit | |
| parent | 04de2fd0eac4d8bedad33b1efcd0c0f1ab093662 (diff) | |
| download | pygerrit-c87e4bc55eb701b4ceb9fa77d29bc2ba61bb4063.tar.gz | |
Fix authentication setup
Change-Id: I8a7557818cd3c207035ef627e6912ee945c083c6
Diffstat (limited to 'pygerrit')
| -rw-r--r-- | pygerrit/rest/__init__.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pygerrit/rest/__init__.py b/pygerrit/rest/__init__.py index bfa6fac..8a29147 100644 --- a/pygerrit/rest/__init__.py +++ b/pygerrit/rest/__init__.py @@ -36,10 +36,10 @@ class GerritRestAPIAuthentication(requests.auth.HTTPDigestAuth): def __init__(self, url, username=None, password=None): self.username = username self.password = password - if not (self.username and self.password): + if not self.has_credentials(): (self.username, self.password) = \ requests.utils.get_netrc_auth(url) - if (self.username and self.password): + if self.has_credentials(): super(GerritRestAPIAuthentication, self).__init__(self.username, self.password) @@ -48,9 +48,9 @@ class GerritRestAPIAuthentication(requests.auth.HTTPDigestAuth): req = super(GerritRestAPIAuthentication, self).__call__(req) return req - def is_authenticated(self): + def has_credentials(self): """ Return True if authentication credentials are present. """ - return (self.username and self.password) + return (self.username is not None and self.password is not None) class GerritRestAPIError(Exception): @@ -115,7 +115,7 @@ class GerritRestAPI(object): self.url = url.rstrip('/') auth = GerritRestAPIAuthentication(url, username, password) - if auth.is_authenticated(): + if auth.has_credentials(): self.kwargs['auth'] = auth if not self.url.endswith(GERRIT_AUTH_SUFFIX): self.url += GERRIT_AUTH_SUFFIX |
