관리-도구
편집 파일: utils.cpython-311.pyc
� �܋fT� � �� � d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl Z d dlmZ d dl m Z d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d lmZ d d lmZ n)# e$ r! d dlmZ d dlmZ d dlmZ d d lmZ d d lmZ Y nw xY w d dlmZ n # e$ r dZY nw xY wd dlmZ d d lm Z d dlm!Z! dZ"n # e$ r dZ"Y nw xY wd dl#Z#d dl$m%Z%m&Z&m'Z'm(Z(m)Z)mZ d dl*m+Z+ d dl,m-Z- e+r*d dl.m/Z/m0Z0 d dl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< d dl*m=Z=m>Z> eddd� � Z? ej@ d� � ZA ejB d� � ZCdZDd� ZEd� ZFd� ZGd� ZH G d � d!eI� � ZJ eJ� � ZKd"� ZLd#� ZMd$� ZNd%� ZOdjd&�ZP G d'� d(eQ� � ZRe( G d)� d*eI� � � � ZS G d+� d,eI� � ZT G d-� d.eI� � ZUe+rd d/l1mVZV eVd0� � ZWe<eUeWf ZXd1� ZYd2� ZZd3� Z[d4� Z\ dkd5�Z] djd6�Z^d7� Z_e%rd8� Z`nd9� Z`d:� Za dld;�Zb dmd<�Zcd=� Zd dnd>�Ze efegd?� � Zhehrd@� ZindA� Zi dodB�Zj dpdC�ZkdD� ZldE� ZmdF� ZndkdG�ZodjdH�ZpdI� Zq dpdJ�ZrdK� ZsdL� ZtdM� ZudjdN�ZvdO� ZwdP� ZxdQ� Zy ey� � \ ZzZ{dRZ|dS� Z}dT� Z~ e{dU� � Z G dV� dWeg� � Z� G dX� dYe j� � � Z�dZ� Z�d[� Z� ed\g d]�� � Z�dqd^�Z� ed_g d`�� � Z�drda�Z�db� Z�dsdc�Z�dd� Z�e'rde� Z�n e&rdf� Z�ndg� Z�e%rdh� Z�dS di� Z�dS )t� N)� namedtuple)�copy)�Decimal)�Real)�parse_qs)�unquote)� urlencode)�urlsplit)� urlunsplit)�BaseExceptionGroup)�datetime)�partial)� partialmethodTF)�PY2�PY33�PY37�implements_str� text_type�urlparse)� TYPE_CHECKING)�DEFAULT_MAX_VALUE_LENGTH)� FrameType� TracebackType)�Any�Callable�ContextManager�Dict�Iterator�List�Optional�Set�Tuple�Type�Union)�EndpointType�ExcInfoi� � zsentry_sdk.errorsz^[a-zA-Z0-9/+=]*$z [Filtered]c �V � t j | dd�� � � d� � S )zCSerialize data into a compact JSON representation encoded as UTF-8.F)�,�:)� allow_nan� separators�utf-8)�json�dumps�encode)�datas �G/opt/cloudlinux/venv/lib64/python3.11/site-packages/sentry_sdk/utils.py� json_dumpsr3 U s) � � �:�d�e� �C�C�C�J�J�7�S�S�S� c � � d S �N� r7 r4 r2 �_get_debug_hubr8 [ s � � �Dr4 c �$ � t j � d� � } | r| S t t j j d� � 5 } t j g d�t j ||�� � � � � d � � � � d� � } n# t t f$ r Y nw xY w| r| cddd� � S ddd� � n# 1 swxY w Y dD ]'}t j � |� � } | r| c S �(dS ) zTry to guess a default release.�SENTRY_RELEASEzw+)�gitz rev-parse�HEAD)�stdout�stderr�stdinr r- N)�HEROKU_SLUG_COMMIT�SOURCE_VERSION�!CODEBUILD_RESOLVED_SOURCE_VERSION�CIRCLE_SHA1�GAE_DEPLOYMENT_ID)�os�environ�get�open�path�devnull� subprocess�Popen�PIPE�communicate�strip�decode�OSError�IOError)�release�null�vars r2 �get_default_releaserV a s� � � �j�n�n�-�.�.�G�� ��� �b�g�o�t� $� $� �� �� �0�0�0�%�?��� � � � ����q� "� ��������� �G�� ��!� � � ��D� ���� � ��#� � � � � � � � �!� � � � � � � � � � ���� � � � �&� � �� �*�.�.��%�%��� ��N�N�N� ��4s7 �C�A!B'�&C�'B;�8C�:B;�;C�C�"Cc �N � g d�}|D ]}|| v rd� |� � c S �dS )zAReturn the SDK name including the name of the used web framework.)�django�flask�fastapi�bottle�falcon�quart�sanic� starlette�chalice� serverless�pyramid�tornado�aiohttp� aws_lambda�gcp�beam�asgi�wsgizsentry.python.{}z sentry.python)�format)�installed_integrations�framework_integrations�integrations r2 �get_sdk_namern � sW � �� � ��* .� :� :���0�0�0�%�,�,�[�9�9�9�9�9� 1� �?r4 c � � e Zd ZdZd� Zd� ZdS )�CaptureInternalExceptionr7 c � � | S r6 r7 ��selfs r2 � __enter__z"CaptureInternalException.__enter__� s � ��r4 c �2 � |�|�t |||f� � dS )NT)�capture_internal_exception)rs �ty�value�tbs r2 �__exit__z!CaptureInternalException.__exit__� s% � � �>�e�/�&��E�2��7�7�7��tr4 N)�__name__� __module__�__qualname__� __slots__rt rz r7 r4 r2 rp rp � s7 � � � � � ��I�� � �� � � � r4 rp c � � t S r6 )�_CAPTURE_INTERNAL_EXCEPTIONr7 r4 r2 �capture_internal_exceptionsr� � s � �&�&r4 c �T � t � � }|�|� | � � d S d S r6 )r8 �_capture_internal_exception)�exc_info�hubs r2 rv rv � s3 � � � � �C� ���'�'��1�1�1�1�1� �r4 c �: � | t z � � � S r6 )�epoch� total_seconds�rx s r2 �to_timestampr� � s � ��E�M�(�(�*�*�*r4 c �, � | � d� � S )Nz%Y-%m-%dT%H:%M:%S.%fZ)�strftimer� s r2 �format_timestampr� � s � ��>�>�1�2�2�2r4 c �h � | �t j � � } nt | � � } | d �d} d| iS )z+Creates a hint with the exc info filled in.Nr r� )�sysr� �exc_info_from_error�r� s r2 �event_hint_with_exc_infor� � s>