def authenticate_cookie(controller, cookie_path, suppress_ctl_errors=True):
 cookie_data = _read_cookie(cookie_path, False)
 try:
  auth_token_hex = binascii.b2a_hex(stem.util.str_tools._to_bytes(cookie_data))
  msg = ('AUTHENTICATE %s' % stem.util.str_tools._to_unicode(auth_token_hex))
  auth_response = _msg(controller, msg)
  if (str(auth_response) != 'OK'):
   try:
    controller.connect()
   except:
    pass
   if (('*or* authentication cookie.' in str(auth_response)) or ('Authentication cookie did not match expected value.' in str(auth_response))):
    raise IncorrectCookieValue(str(auth_response), cookie_path, False, auth_response)
   else:
    raise CookieAuthRejected(str(auth_response), cookie_path, False, auth_response)
 except stem.ControllerError as exc:
  try:
   controller.connect()
  except:
   pass
  if (not suppress_ctl_errors):
   raise exc
  else:
   raise CookieAuthRejected(('Socket failed (%s)' % exc), cookie_path, False)

def authenticate_cookie ( controller , cookie_path , suppress_ctl_errors = True ) : cookie_data = _read_cookie ( cookie_path , False ) try : auth_token_hex = binascii . b2a_hex ( stem . util . str_tools . _to_bytes ( cookie_data ) ) msg = ( 'AUTHENTICATE %s' % stem . util . str_tools . _to_unicode ( auth_token_hex ) ) auth_response = _msg ( controller , msg ) if ( str ( auth_response ) != 'OK' ) : try : controller . connect ( ) except : pass if ( ( '*or* authentication cookie.' in str ( auth_response ) ) or ( 'Authentication cookie did not match expected value.' in str ( auth_response ) ) ) : raise IncorrectCookieValue ( str ( auth_response ) , cookie_path , False , auth_response ) else : raise CookieAuthRejected ( str ( auth_response ) , cookie_path , False , auth_response ) except stem . ControllerError as exc : try : controller . connect ( ) except : pass if ( not suppress_ctl_errors ) : raise exc else : raise CookieAuthRejected ( ( 'Socket failed (%s)' % exc ) , cookie_path , False )
authenticates to a control socket that uses the contents of an authentication cookie .