Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/raven/contrib/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/raven/contrib/__pycache__/flask.cpython-311.pyc

�

�܋fA+��T�dZddlmZ	ddlmZdZn
#e$rdZYnwxYwddlZddlZddl	m
Z
mZmZddl
mZmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlm Z m!Z!ddl"m#Z#ej$��Z%e%�&d��Z'dd�Z(Gd�de)��ZdS)z�
raven.contrib.flask
~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
�)�absolute_import)�current_userTFN)�request�current_app�g)�got_request_exception�request_finished)�ClientDisconnected)�
setup_logging)�Client)�Sentry)�
SentryHandler)�urlparse)�
to_unicode)�get_headers�get_environ)�convert_options�logging_configuredc���|dit|j|t|j�dg����t|jg��z|j�dg��d|id������S)N�SENTRY_INCLUDE_PATHS�RAVEN_IGNORE_EXCEPTIONS�app)�dsn�
include_paths�ignore_exceptions�extra)�defaults�)r�config�set�get�import_name)�
client_clsrrs   �d/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/raven/contrib/flask.py�make_clientr%'s����:���
��J����
���'=�r�B�B�C�C��3�?�+�,�,�-�&)�Z�^�^�4M�r�%R�%R��3����
�
�
����c	���eZdZdZddedddejddf	d�Zed���Z	e	j
d���Z	d�Zd	�Zd
�Z
d�Zd�Zd
�Zdd�Zd�Zd�Z			dd�Zd�Zd�Zd�Zd�Zd�ZdS)r
a�
    Flask application for Sentry.

    Look up configuration from ``os.environ['SENTRY_DSN']``::

    >>> sentry = Sentry(app)

    Pass an arbitrary DSN::

    >>> sentry = Sentry(app, dsn='http://public:secret@example.com/1')

    Pass an explicit client::

    >>> sentry = Sentry(app, client=client)

    Automatically configure logging::

    >>> sentry = Sentry(app, logging=True, level=logging.ERROR)

    Capture an exception::

    >>> try:
    >>>     1 / 0
    >>> except ZeroDivisionError:
    >>>     sentry.captureException()

    Capture a message::

    >>> sentry.captureMessage('hello, world!')

    By default, the Flask integration will do the following:

    - Hook into the `got_request_exception` signal. This can be disabled by
      passing `register_signal=False`.
    - Wrap the WSGI application. This can be disabled by passing
      `wrap_wsgi=False`.
    - Capture information from Flask-Login (if available).
    NFTc
���|r$t|t��std���||_||_||_||_||_||_||_	|	|_
|r|�|��dSdS)Nz&client should be an instance of Client)�
isinstancer�	TypeErrorr�logging�logging_exclusionsr#�client�level�	wrap_wsgi�register_signal�init_app)
�selfrr-r#rr+r,r.r/r0s
          r$�__init__zSentry.__init__es����	F�*�V�V�4�4�	F��D�E�E�E�������"4���$��������
�"���.����	��M�M�#������	�	r&c�^�	tjS#t$rYnwxYwt|dd��S)N�_last_event_id)r�sentry_event_id�	Exception�getattr)r2s r$�
last_event_idzSentry.last_event_idwsC��	��$�$���	�	�	��D�	�����t�-�t�4�4�4s��
�c�P�||_	|t_dS#t$rYdSwxYw�N)r5rr6r7)r2�values  r$r9zSentry.last_event_ids?��#���	� %�A������	�	�	��D�D�	���s��
%�%c���|jsdS|�d��}|�(t|d��rt|��||jf}n|�d��}|�|���dS)N�	exception�
__traceback__�exc_info)r@)r-r!�hasattr�typer?�captureException)r2�args�kwargsr>r@s     r$�handle_exceptionzSentry.handle_exception�s����{�	��F��J�J�{�+�+�	�� �W�Y��%H�%H� ��Y����I�4K�L�H�H��z�z�*�-�-�H����x��0�0�0�0�0r&c���i}	|jd}n#t$r
|j}YnwxYw|r||d<ts|St	t
d��s|S	tj}n#t$r|cYSwxYwt|��r
|��}|s|St
j
��|d<dt
jvrBt
jdD]/}t	t|��rtt|��||<�0|S)zu
        Requires Flask-Login (https://pypi.python.org/pypi/Flask-Login/)
        to be installed and setup.
        r�
ip_address�
login_manager�id�SENTRY_USER_ATTRS)
�access_route�
IndexError�remote_addr�has_flask_loginrArr�is_authenticated�AttributeError�callable�get_idrr8)r2r�	user_inforHrP�attrs      r$�
get_user_infozSentry.get_user_info�sO��
�	�	-� �-�a�0�J�J���	-�	-�	-� �,�J�J�J�	-�����	1�&0�I�l�#��	����{�O�4�4�	���	�+�<�����	�	�	�����		�����$�%�%�	2�/�/�1�1���	���&�-�/�/�	�$���+�"4�4�4�#�*�+>�?�
B�
B���<��.�.�B�&-�l�D�&A�&A�I�d�O���s�
�&�&�A�A-�,A-c��|�|j��r|j}n|j}|�||��S)zR
        Determine how to retrieve actual data by using request.mimetype.
        )�is_json_type�mimetype�
get_json_data�
get_form_data�get_http_info_with_retriever)r2r�	retrievers   r$�
get_http_infozSentry.get_http_info�sE�����W�-�.�.�	+��*�I�I��*�I��0�0��)�D�D�Dr&c��|dkS)Nzapplication/jsonr)r2�content_types  r$rXzSentry.is_json_type�s���1�1�1r&c��|jSr;)�form�r2rs  r$r[zSentry.get_form_data��
���|�r&c��|jSr;)�datarcs  r$rZzSentry.get_json_data�rdr&c
�R�|�|j}tj|j��}	||��}n#t$ri}YnwxYw|j�d|j�|j��|j|j	|tt|j����tt|j����d�S)zT
        Exact method for getting http_info but with form data work around.
        Nz://)�url�query_string�methodrf�headers�env)r[r�urlsplitrhr
�scheme�netloc�path�queryrj�dictr�environr)r2rr]�urlpartsrfs     r$r\z#Sentry.get_http_info_with_retriever�s������*�I��$�W�[�1�1��	��9�W�%�%�D�D��!�	�	�	��D�D�D�	����#+�/�/�/�8�?�?�H�M�M�R�$�N��n���K���8�8�9�9���G�O�4�4�5�5�

�
�	
s�0�?�?c�d�d|_tjr.|jj�tjj��	|j�|�t����nC#t$r6}|jj
�t|����Yd}~nd}~wwxYw	|j�
|�t����dS#t$r7}|jj
�t|����Yd}~dSd}~wwxYwr;)r9r�url_ruler-�transaction�push�rule�http_contextr^r7�loggerr>r�user_contextrV)r2rDrE�es    r$�before_requestzSentry.before_request�s-��!�����	@��K�#�(�(��)9�)>�?�?�?�	8��K�$�$�T�%7�%7��%@�%@�A�A�A�A���	8�	8�	8��K��(�(��A���7�7�7�7�7�7�7�7�����	8����	8��K�$�$�T�%7�%7��%@�%@�A�A�A�A�A���	8�	8�	8��K��(�(��A���7�7�7�7�7�7�7�7�7�����	8���s0�2A6�6
B6�,B1�1B6�:2C.�.
D/�8,D*�*D/c���|jr|j|jd<|jj���t
jr.|jj�t
jj	��|S)NzX-Sentry-ID)
r9rkr-�context�clearrrvrw�popry)r2�sender�responserDrEs     r$�
after_requestzSentry.after_request�sd����	A�.2�.@�H��]�+����!�!�#�#�#���	?��K�#�'�'��(8�(=�>�>�>��r&c�B�|�||_|�||_|�||_n|j�|r|jrd|_nd|_|�||_|�||_|�||_|js t|j	||j��|_|jr|i}|j�
|j|d<t|j|j���}	t|	fi|��|jj
dur|j�|	��tj|fdti|��|jrt#|j|j��|_|�|j��t)j|j|���|jrt/j|j|���t3|d��si|_||jd<dS)	NFT�exclude)r.�sentry_handler)r��
extensions�sentry)rr.r/�debugr0r+r,r-r%r#rrr{�	propagate�
addHandlerr�send�SentryMiddleware�wsgi_appr~r	�connectr�rrFrAr�)
r2rrr+r.r,r/r0rE�handlers
          r$r1zSentry.init_apps����?��D�H����D�J�� �&�D�N�N�
�^�
#��
&�s�y�
&�!&����!%����&�#2�D� ���"�D�L��)�&8�D�#��{�	F�%�d�o�s�D�H�E�E�D�K��<�	>��F��&�2�$(�$;��y�!�#�D�K�t�z�B�B�B�G��'�,�,�V�,�,�,��z�#�u�,�,��
�%�%�g�.�.�.��#��
>�
>�%2�
>�6<�
>�
>�
>��>�	G�+�C�L�$�+�F�F�C�L����4�.�/�/�/�� ��!3�C�@�@�@�@���	M�!�)�$�*?��L�L�L�L��s�L�)�)�	 ��C�N�#'���x� � � r&c��|js
Jd���|jj|i|��}|r |j�|��|_nd|_|S)Nz5captureException called before application configured)r-rC�	get_identr9�r2rDrE�results    r$rCzSentry.captureException<sa���{�S�S�S�S�S�{�-���-�t�>�v�>�>���	&�!%��!6�!6�v�!>�!>�D���!%�D���
r&c��|js
Jd���|jj|i|��}|r |j�|��|_nd|_|S)Nz3captureMessage called before application configured)r-�captureMessager�r9r�s    r$r�zSentry.captureMessageEsa���{�Q�Q�Q�Q�Q�{�+���+�T�<�V�<�<���	&�!%��!6�!6�v�!>�!>�D���!%�D���
r&c�H�|js
Jd���|jj|i|��S)Nz1user_context called before application configured)r-r|�r2rDrEs   r$r|zSentry.user_contextN�2���{�O�O�O�O�O�{�'�t�{�'��8��8�8�8r&c�H�|js
Jd���|jj|i|��S)Nz1tags_context called before application configured)r-�tags_contextr�s   r$r�zSentry.tags_contextRr�r&c�H�|js
Jd���|jj|i|��S)Nz2extra_context called before application configured)r-�
extra_contextr�s   r$r�zSentry.extra_contextVs2���{�P�P�P�P�P�{�(�t�{�(�$�9�&�9�9�9r&r;)NNNNNN)�__name__�
__module__�__qualname__�__doc__rr+�NOTSETr3�propertyr9�setterrFrVr^rXr[rZr\r~r�r1rCr�r|r�r�rr&r$r
r
;s�������%�%�R ���T��4�w�~�������$�5�5��X�5��������
1�
1�
1�*�*�*�XE�E�E�2�2�2�������
�
�
�
�.
8�
8�
8����;?�48�!%�7(�7(�7(�7(�r������9�9�9�9�9�9�:�:�:�:�:r&r
r;)*r��
__future__r�flask_loginrrO�ImportErrorr+�blinker�flaskrrr�
flask.signalsrr	�werkzeug.exceptionsr
�
raven.confr�
raven.baser�raven.middlewarer
r��raven.handlers.loggingr�raven.utils.compatr�raven.utils.encodingr�raven.utils.wsgirr�raven.utils.confr�	Namespace�
raven_signals�signalrr%�objectrr&r$�<module>r�s�����'�&�&�&�&�&��(�(�(�(�(�(��O�O�������O�O�O�����
��������)�)�)�)�)�)�)�)�)�)�A�A�A�A�A�A�A�A�2�2�2�2�2�2�$�$�$�$�$�$�������7�7�7�7�7�7�0�0�0�0�0�0�'�'�'�'�'�'�+�+�+�+�+�+�5�5�5�5�5�5�5�5�,�,�,�,�,�,�"��!�#�#�
�"�)�)�*>�?�?������(]:�]:�]:�]:�]:�V�]:�]:�]:�]:�]:s���

Hacked By AnonymousFox1.0, Coded By AnonymousFox