<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from functools import partial <EOL> from raven . transport . base import AsyncTransport <EOL> from raven . transport . http import HTTPTransport <EOL> try : <EOL> from tornado import ioloop <EOL> from tornado . httpclient import AsyncHTTPClient , HTTPClient <EOL> has_tornado = True <EOL> except : <EOL> has_tornado = False <EOL> class TornadoHTTPTransport ( AsyncTransport , HTTPTransport ) : <EOL> scheme = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __init__ ( self , parsed_url , * args , ** kwargs ) : <EOL> if not has_tornado : <EOL> raise ImportError ( '<STR_LIT>' ) <EOL> super ( TornadoHTTPTransport , self ) . __init__ ( parsed_url , * args , ** kwargs ) <EOL> def async_send ( self , data , headers , success_cb , failure_cb ) : <EOL> kwargs = dict ( method = '<STR_LIT:POST>' , headers = headers , body = data ) <EOL> kwargs [ "<STR_LIT>" ] = self . verify_ssl <EOL> kwargs [ "<STR_LIT>" ] = self . timeout <EOL> kwargs [ "<STR_LIT>" ] = self . ca_certs <EOL> if ioloop . IOLoop . initialized ( ) : <EOL> client = AsyncHTTPClient ( ) <EOL> kwargs [ '<STR_LIT>' ] = None <EOL> future = client . fetch ( self . _url , ** kwargs ) <EOL> ioloop . IOLoop . current ( ) . add_future ( future , partial ( self . handler , success_cb , failure_cb ) ) <EOL> else : <EOL> client = HTTPClient ( ) <EOL> try : <EOL> client . fetch ( self . _url , ** kwargs ) <EOL> success_cb ( ) <EOL> except Exception as e : <EOL> failure_cb ( e ) <EOL> @ staticmethod <EOL> def handler ( success , error , future ) : <EOL> try : <EOL> future . result ( ) <EOL> success ( ) <EOL> except Exception as e : <EOL> error ( e ) </s>
