Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_password_from_keyring(username):
result = keyring.get_password(
KEYRING_SYSTEM,
username
)
if result is None:
raise NoStoredPasswordAvailable(
"No pyicloud password for {username} could be found "
"in the system keychain. Use the `--store-in-keyring` "
"command-line option for storing a password for this "
"username.".format(
username=username,
)
)
return result
def password_exists_in_keyring(username):
try:
get_password_from_keyring(username)
except NoStoredPasswordAvailable:
return False
return True