def get_username_password(storage_name, user_input=input, password_input=getpass, output=print): user = keyring.get_password("MosaiqSQL_username", storage_name) password = keyring.get_password("MosaiqSQL_password", storage_name) if user is None or user == "": output("Provide a user that only has `db_datareader` access to the " "Mosaiq database at `{}`".format(storage_name)) user = user_input() if user == "": error_message = "Username should not be blank." output(error_message) raise ValueError(error_message) keyring.set_password("MosaiqSQL_username", storage_name, user) if password is None: output("Provide password for '{}' server and '{}' user".format( storage_name, user)) password = password_input() keyring.set_password("MosaiqSQL_password", storage_name, password) return user, password
def set_zenodo_access_token(access_token, hostname=ZENODO_HOSTNAME): keyring.set_password("Zenodo", hostname, access_token)