def authenticate_password(controller, password, suppress_ctl_errors=True):
 password = password.replace('"', '\\"')
 try:
  auth_response = _msg(controller, ('AUTHENTICATE "%s"' % password))
  if (str(auth_response) != 'OK'):
   try:
    controller.connect()
   except:
    pass
   if ('Password did not match HashedControlPassword' in str(auth_response)):
    raise IncorrectPassword(str(auth_response), auth_response)
   else:
    raise PasswordAuthRejected(str(auth_response), auth_response)
 except stem.ControllerError as exc:
  try:
   controller.connect()
  except:
   pass
  if (not suppress_ctl_errors):
   raise exc
  else:
   raise PasswordAuthRejected(('Socket failed (%s)' % exc))

def authenticate_password ( controller , password , suppress_ctl_errors = True ) : password = password . replace ( '"' , '\\"' ) try : auth_response = _msg ( controller , ( 'AUTHENTICATE "%s"' % password ) ) if ( str ( auth_response ) != 'OK' ) : try : controller . connect ( ) except : pass if ( 'Password did not match HashedControlPassword' in str ( auth_response ) ) : raise IncorrectPassword ( str ( auth_response ) , auth_response ) else : raise PasswordAuthRejected ( str ( auth_response ) , auth_response ) except stem . ControllerError as exc : try : controller . connect ( ) except : pass if ( not suppress_ctl_errors ) : raise exc else : raise PasswordAuthRejected ( ( 'Socket failed (%s)' % exc ) )
authenticates to a control socket that uses a password .