def store_password_in_keyring(credential_id, username, password=None):
 try:
  import keyring
  import keyring.errors
  if (password is None):
   prompt = 'Please enter password for {0}: '.format(credential_id)
   try:
    password = getpass.getpass(prompt)
   except EOFError:
    password = None
   if (not password):
    raise RuntimeError('Invalid password provided.')
  try:
   _save_password_in_keyring(credential_id, username, password)
  except keyring.errors.PasswordSetError as exc:
   log.debug('Problem saving password in the keyring: {0}'.format(exc))
 except ImportError:
  log.error('Tried to store password in keyring, but no keyring module is installed')
  return False

def store_password_in_keyring ( credential_id , username , password = None ) : try : import keyring import keyring . errors if ( password is None ) : prompt = 'Please enter password for {0}: ' . format ( credential_id ) try : password = getpass . getpass ( prompt ) except EOFError : password = None if ( not password ) : raise RuntimeError ( 'Invalid password provided.' ) try : _save_password_in_keyring ( credential_id , username , password ) except keyring . errors . PasswordSetError as exc : log . debug ( 'Problem saving password in the keyring: {0}' . format ( exc ) ) except ImportError : log . error ( 'Tried to store password in keyring, but no keyring module is installed' ) return False
interactively prompts user for a password and stores it in system keyring .