<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
σ
ΏφYc           @@  s   d  Z  d d l m Z d d l m Z d d l m Z d d l m Z m	 Z	 d d l
 m	 Z d d l m Z d e f d	     YZ d
 e f d     YZ d S(   s    
raven.contrib.tornado
~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2012 by the Sentry Team, see AUTHORS for more details
:license: BSD, see LICENSE for more details
i    (   t   absolute_import(   t   partial(   t   ioloop(   t   AsyncHTTPClientt	   HTTPError(   R   (   t   Clientt   AsyncSentryClientc           B@  sV   e  Z d  Z d   Z d   Z d d d  Z d d d  Z d   Z d d d  Z	 RS(   sΊ   
    A mixin class that could be used along with request handlers to
    asynchronously send errors to sentry. The client also captures the
    information from the request handlers
    c         O@  s2   | j  d t  |  _ t t |   j | |   d  S(   Nt   validate_cert(   t   popt   TrueR   t   superR   t   __init__(   t   selft   argst   kwargs(    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyR      s    c         O@  sQ   |  j    s d S|  j | |   } |  j d | j d d  |  } | d | f S(   s	  
        Takes the same arguments as the super function in :py:class:`Client`
        and extracts the keyword argument callback which will be called on
        asynchronous sending of the request

        :return: a 32-length string identifying this event
        Nt   callbackt   event_id(   t
   is_enabledt	   build_msgt   sendt   gett   None(   R   R   R   t   datat   future(    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   capture   s
    !c         K@  s(   |  j  |  } |  j | d | d | S(   sV   
        Serializes the message and passes the payload onto ``send_encoded``.
        t   auth_headerR   (   t   encodet   send_encoded(   R   R   R   R   t   message(    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyR   /   s    c      	   C@  s   | d  k r i  } n  |  j j   sD |  j |  } |  j |  d  S|  j d | d | d | d |  } t j j   j	 | t
 |  j | |   | S(   Nt   urlR   t   headersR   (   R   t   statet
   should_tryt   decodet   _log_failed_submissiont   _send_remoteR   t   IOLoopt   currentt
   add_futureR   t   _handle_result(   R   R   R   R   R   R   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   send_remote7   s    		(c         C@  s   y | j    Wni t k
 rE } |  j |  } |  j | | |  nB t k
 ry } |  j |  } |  j | | |  n X|  j j   d  S(   N(   t   resultR   R!   t   _failed_sendt	   ExceptionR   t   set_success(   R   R   R   R   t   e(    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyR'   F   s    c         C@  sC   | d k r i  } n  t   j | | d d d | d | d |  j S(   s±   
        Initialise a Tornado AsyncClient and send the reuqest to the sentry
        server. If the callback is a callable, it will be called with the
        response.
        t   methodt   POSTt   bodyR   R   N(   R   R   t   fetchR   (   R   R   R   R   R   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyR#   R   s
    		N(
   t   __name__t
   __module__t   __doc__R   R   R   R   R(   R'   R#   (    (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyR      s   			t   SentryMixinc           B@  sq   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d d  Z	 d d  Z
 d   Z d	   Z d
 d  Z RS(   s  
    A mixin class that extracts information from the Request in a Request
    Handler to capture and send to sentry. This mixin class is designed to be
    used along with `tornado.web.RequestHandler`

    .. code-block:: python
        :emphasize-lines: 6

        class MyRequestHandler(SentryMixin, tornado.web.RequestHandler):
            def get(self):
                try:
                    fail()
                except Exception as e:
                    self.captureException()


    While the above example would result in sequential execution, an example
    for asynchronous use would be

    .. code-block:: python
        :emphasize-lines: 6

        class MyRequestHandler(SentryMixin, tornado.web.RequestHandler):

            @tornado.web.asynchronous
            @tornado.gen.engine
            def get(self):
                # Do something and record a message in sentry
                response = yield tornado.gen.Task(
                    self.captureMessage, "Did something really important"
                )
                self.write("Your request to do something important is done")
                self.finish()


    The mixin assumes that the application will have an attribute called
    `sentry_client`, which should be an instance of
    :py:class:`AsyncSentryClient`. This can be changed by implementing your
    own get_sentry_client method on your request handler.
    c         C@  s
   |  j  j S(   sΐ   
        Returns the sentry client configured in the application. If you need
        to change the behaviour to do something else to get the client, then
        subclass this method
        (   t   applicationt   sentry_client(   R   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   get_sentry_client   s    c         C@  sn   i i |  j  j   d 6|  j  j d 6|  j  j d 6|  j  j d 6|  j  j j d d	  d 6t |  j  j  d 6d 6S(
   s΅   
        Extracts the data required for 'sentry.interfaces.Http' from the
        current request being handled by the request handler

        :param return: A dictionary.
        R   R.   R   t   query_stringt   Cookiet   cookiesR   t   requestN(	   R<   t   full_urlR.   R0   t   queryR   R   R   t   dict(   R   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   get_sentry_data_from_request   s    c         C@  sC   y |  j    } Wn t k
 r$ i  SXi i | r7 t n t d 6d 6S(   sι   
        Data for sentry.interfaces.User

        Default implementation only sends `is_authenticated` by checking if
        `tornado.web.RequestHandler.get_current_user` tests postitively for on
        Truth calue testing
        t   is_authenticatedt   user(   t   get_current_userR+   R	   t   False(   R   RB   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   get_sentry_user_info₯   s    c         C@  s   i i  d 6S(   sf   
        Subclass and implement this method if you need to send any extra
        information
        t   extra(    (   R   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   get_sentry_extra_info·   s    c         C@  sC   i  } | j  |  j    | j  |  j    | j  |  j    | S(   N(   t   updateR@   RE   RG   (   R   R   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   get_default_contextΑ   s
    c         K@  s   | d  k r |  j   } n? |  j   } t | t  rF | j |  n | | d d <| } |  j   } t | |  d | |  S(   NRF   t
   extra_dataR   (   R   RI   t
   isinstanceR?   RH   R8   t   getattr(   R   t	   call_nameR   R   t   default_contextt   client(    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   _captureΟ   s    c         K@  s   |  j  d d | | S(   Nt   captureExceptiont   exc_info(   RP   (   R   RR   R   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyRQ   ή   s    c         K@  s   |  j  d d | | S(   Nt   captureMessageR   (   RP   (   R   R   R   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyRS   α   s    c         C@  sl   t  t |   j | | |  } t | t  rO | j d k  sK | j d k rO | S|  j d | | | f  | S(   sv   Override implementation to report all exceptions to sentry.
        log_exception() is added in Tornado v3.1.
        iτ  iW  RR   (   R
   R5   t   log_exceptionRK   t   WebHTTPErrort   status_codeRQ   (   R   t   typt   valuet   tbt   rv(    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyRT   δ   s
    -iτ  c         K@  s   t  t t |   d  r1 t t |   j | |  St t |   j | |  } d | k oc d k n r |  j d | j d   n  | Sd S(   s   Override implementation to report all exceptions to sentry, even
        after self.flush() or self.finish() is called, for pre-v3.1 Tornado.
        RT   iτ  iW  RR   N(   t   hasattrR
   R5   t
   send_errorRQ   R   (   R   RV   R   RZ   (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyR\   ο   s    N(   R2   R3   R4   R8   R@   RE   RG   RI   R   RP   RQ   RS   RT   R\   (    (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyR5   a   s   (				
			N(   R4   t
   __future__R    t	   functoolsR   t   tornadoR   t   tornado.httpclientR   R   t   tornado.webRU   t
   raven.baseR   R   t   objectR5   (    (    (    sO   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/tornado/__init__.pyt   <module>   s   N