£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>

Yc           @@  s   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 d d l
 m Z e j d  Z d   Z d	 e	 f d
     YZ d S(   s   
raven.contrib.awslambda
~~~~~~~~~~~~~~~~~~~~

Raven wrapper for AWS Lambda handlers.

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
i    (   t   absolute_importN(   t   FunctionType(   t   Client(   t   HTTPTransports   sentry.errors.clientc           C@  s.   i d d 6d d 6d d 6d d 6d	 d
 6d d 6S(   Nt   AWS_LAMBDA_FUNCTION_NAMEt   lambdat   AWS_LAMBDA_FUNCTION_VERSIONt   versiont   AWS_LAMBDA_FUNCTION_MEMORY_SIZEt   memory_sizet   AWS_LAMBDA_LOG_GROUP_NAMEt	   log_groupt   AWS_LAMBDA_LOG_STREAM_NAMEt
   log_streamt
   AWS_REGIONt   region(    (    (    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyt   get_default_tags   s    t   LambdaClientc           B@  se   e  Z d  Z d   Z d   Z d   Z d d d  Z e d    Z	 e d    Z
 e d    Z RS(	   s  
    Raven decorator for AWS Lambda.

    By default, the lambda integration will capture unhandled exceptions and instrument logging.

    Usage:

    >>> from raven.contrib.awslambda import LambdaClient
    >>>
    >>>
    >>> client = LambdaClient()
    >>>
    >>> @client.capture_exceptions
    >>> def handler(event, context):
    >>>    ...
    >>>    raise Exception('I will be sent to sentry!')

    c         O@  s5   | j  d t  } t t |   j d | | |  d  S(   Nt	   transport(   t   getR   t   superR   t   __init__(   t   selft   argst   kwargsR   (    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR   8   s    c         O@  s   d | k r i  | d <} n
 | d } | j  d d   } | j  d d   } |  j |  } | rp | j |  n  | r |  j |  } | r | j |  n  |  j | |  | d <n  t t |   j | |   S(   Nt   datat   eventt   contextt   extra(	   R   t   Nonet   _get_user_interfacet   updatet   _get_http_interfacet   _get_extra_dataR   R   t   capture(   R   R   R   R   R   R   t	   user_infot	   http_info(    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR"   <   s    
c         O@  s   t  t |   j | |   } x= t   j   D], \ } } | d j | t j j |   q+ W| j d t j j d   | j d t j j d   | S(   Nt   tagst   releaset   SENTRY_RELEASEt   environmentt   SENTRY_ENVIRONMENT(	   R   R   t	   build_msgR   t   itemst
   setdefaultt   ost   environR   (   R   R   R   R   t   optiont   default(    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR*   M   s    $c         @  s\   t   t  s% t j  j d  S  p1 t f   t j       f d    } | S(   s  
        Wrap a function or code block in try/except and automatically call
        ``.captureException`` if it raises an exception, then the exception
        is reraised.

        By default, it will capture ``Exception``

        >>> @client.capture_exceptions
        >>> def foo():
        >>>     raise Exception()

        >>> with client.capture_exceptions():
        >>>    raise Exception()

        You can also specify exceptions to be caught specifically

        >>> @client.capture_exceptions((IOError, LookupError))
        >>> def bar():
        >>>     ...

        ``kwargs`` are passed through to ``.captureException``.
        t
   exceptionsc         @  sX   y  |  | | |  SWn:   k
 rS  j  d |  d | |   j j     n Xd  S(   NR   R   (   t   captureExceptionR   t   clear(   R   R   R   R   (   R1   t   fR   (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyt   wrappedt   s    (   t
   isinstanceR   t	   functoolst   partialt   capture_exceptionst	   Exceptiont   wraps(   R   R4   R1   R5   (    (   R1   R4   R   sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR9   V   s
    $c         C@  s   |  j  d  r |  d d } | r i | j  d d   pG | j  d d   d 6| j  d d   d 6| j  d d   d 6| j  d	 d   d
 6| j  d d   d 6| j  d  d 6} i | d 6Sn  d  S(   Nt   requestContextt   identityt   cognitoIdentityIdt   usert   idt   usernamet   sourceIpt
   ip_addresst   cognitoIdentityPoolIdt   cognito_identity_pool_idt   cognitoAuthenticationTypet   cognito_authentication_typet	   userAgentt
   user_agent(   R   R   (   R   R=   R?   (    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR   ~   s    %c         C@  s   |  j  d  r{ |  j  d  r{ i |  j  d  d 6|  j  d  d 6|  j  d d   d 6|  j  d d   pi g  d 6} i | d 6Sd  S(	   Nt   patht
   httpMethodt   urlt   methodt   queryStringParameterst   query_stringt   headerst   request(   R   R   (   R   RQ   (    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR       s    c         C@  s   i |  d 6| j  d 6t |  d 6} | j r i | j j j d 6| j j j d 6| j j j d 6| j j j d 6| j j j d 6| j j	 d	 6| j j
 d
 6| d <n  | S(   NR   t   aws_request_idR   s   client.installation_ids   client.app_titles   client.app_version_names   client.app_version_codes   client.app_package_namet   customt   envt   client_context(   RR   t   varsRU   t   clientt   installation_idt	   app_titlet   app_version_namet   app_version_codet   app_package_nameRS   RT   (   R   R   t   extra_context(    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR!      s    
	N(   t   __name__t
   __module__t   __doc__R   R"   R*   R   R9   t   staticmethodR   R    R!   (    (    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyR   $   s   				((   R`   t
   __future__R    R-   t   loggingR7   t   typesR   t
   raven.baseR   t   raven.transport.httpR   t	   getLoggert   loggerR   R   (    (    (    sQ   /opt/alt/python27/lib/python2.7/site-packages/raven/contrib/awslambda/__init__.pyt   <module>	   s   	