saving dependency work

This commit is contained in:
2022-12-10 21:17:54 -06:00
parent bf923c3406
commit c2c19e5382
5636 changed files with 666283 additions and 8587 deletions
@@ -36,7 +36,8 @@ except ImportError:
keyring = None
except Exception as exc:
logger.warning(
"Keyring is skipped due to an exception: %s", str(exc),
"Keyring is skipped due to an exception: %s",
str(exc),
)
keyring = None
@@ -68,14 +69,14 @@ def get_keyring_auth(url, username):
except Exception as exc:
logger.warning(
"Keyring is skipped due to an exception: %s", str(exc),
"Keyring is skipped due to an exception: %s",
str(exc),
)
keyring = None
return None
class MultiDomainBasicAuth(AuthBase):
def __init__(self, prompting=True, index_urls=None):
# type: (bool, Optional[List[str]]) -> None
self.prompting = prompting
@@ -111,8 +112,7 @@ class MultiDomainBasicAuth(AuthBase):
return u
return None
def _get_new_credentials(self, original_url, allow_netrc=True,
allow_keyring=True):
def _get_new_credentials(self, original_url, allow_netrc=True, allow_keyring=True):
# type: (str, bool, bool) -> AuthInfo
"""Find and return credentials for the specified URL."""
# Split the credentials and netloc from the url.
@@ -152,9 +152,8 @@ class MultiDomainBasicAuth(AuthBase):
# If we don't have a password and keyring is available, use it.
if allow_keyring:
# The index url is more specific than the netloc, so try it first
kr_auth = (
get_keyring_auth(index_url, username) or
get_keyring_auth(netloc, username)
kr_auth = get_keyring_auth(index_url, username) or get_keyring_auth(
netloc, username
)
if kr_auth:
logger.debug("Found credentials in keyring for %s", netloc)
@@ -196,7 +195,8 @@ class MultiDomainBasicAuth(AuthBase):
assert (
# Credentials were found
(username is not None and password is not None) or
(username is not None and password is not None)
or
# Credentials were not found
(username is None and password is None)
), "Could not load credentials from url: {}".format(original_url)
@@ -290,7 +290,8 @@ class MultiDomainBasicAuth(AuthBase):
"""Response callback to warn about incorrect credentials."""
if resp.status_code == 401:
logger.warning(
'401 Error, Credentials not correct for %s', resp.request.url,
"401 Error, Credentials not correct for %s",
resp.request.url,
)
def save_credentials(self, resp, **kwargs):
@@ -304,7 +305,7 @@ class MultiDomainBasicAuth(AuthBase):
self._credentials_to_save = None
if creds and resp.status_code < 400:
try:
logger.info('Saving credentials to keyring')
logger.info("Saving credentials to keyring")
keyring.set_password(*creds)
except Exception:
logger.exception('Failed to save credentials')
logger.exception("Failed to save credentials")