def _read_cookie(cookie_path, is_safecookie):
 if (not os.path.exists(cookie_path)):
  exc_msg = ("Authentication failed: '%s' doesn't exist" % cookie_path)
  raise UnreadableCookieFile(exc_msg, cookie_path, is_safecookie)
 auth_cookie_size = os.path.getsize(cookie_path)
 if (auth_cookie_size != 32):
  exc_msg = ("Authentication failed: authentication cookie '%s' is the wrong size (%i bytes instead of 32)" % (cookie_path, auth_cookie_size))
  raise IncorrectCookieSize(exc_msg, cookie_path, is_safecookie)
 try:
  with open(cookie_path, 'rb', 0) as f:
   return f.read()
 except IOError as exc:
  exc_msg = ("Authentication failed: unable to read '%s' (%s)" % (cookie_path, exc))
  raise UnreadableCookieFile(exc_msg, cookie_path, is_safecookie)

def _read_cookie ( cookie_path , is_safecookie ) : if ( not os . path . exists ( cookie_path ) ) : exc_msg = ( "Authentication failed: '%s' doesn't exist" % cookie_path ) raise UnreadableCookieFile ( exc_msg , cookie_path , is_safecookie ) auth_cookie_size = os . path . getsize ( cookie_path ) if ( auth_cookie_size != 32 ) : exc_msg = ( "Authentication failed: authentication cookie '%s' is the wrong size (%i bytes instead of 32)" % ( cookie_path , auth_cookie_size ) ) raise IncorrectCookieSize ( exc_msg , cookie_path , is_safecookie ) try : with open ( cookie_path , 'rb' , 0 ) as f : return f . read ( ) except IOError as exc : exc_msg = ( "Authentication failed: unable to read '%s' (%s)" % ( cookie_path , exc ) ) raise UnreadableCookieFile ( exc_msg , cookie_path , is_safecookie )
provides the contents of a given cookie file .