관리-도구
편집 파일: utils.cpython-38.pyc
U �Mg�� � @ s| d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl Z d dlZd dlm Z d dlmZmZ d dlmZ d dlmZmZmZ d dlmZ d dlmZmZmZmZmZ zd dlmZ W n e k r� dZY nX d dl!Z!d d l"m#Z# d d l$m%Z%m&Z& d dl'm(Z( e(�r�d dl)m*Z*m+Z+ d d l'm,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z; d dl<m=Z= d dl>m?Z?m@Z@ e6d�ZAe:d�ZBeddd�ZCe�Dd�ZEdaFe�Gd�ZHdZIeJd�ZKeJd�ZLdd�dd�ZMdd� ZNdd � ZOd!d"� ZPd#d$� ZQG d%d&� d&�ZReR� ZSd'd(� ZTd)d*� ZUd+d,� ZVd-d.� ZWeJd/�ZXd0d1� ZYd�d2d3�ZZG d4d5� d5e[�Z\G d6d7� d7�Z]G d8d9� d9�Z^G d:d;� d;�Z_e(�r�d d<l'm:Z: e:d=�Z`e;e_e`f Zad>d?� Zbd@dA� ZcdBdC� ZddDdE� Zed�dFdG�Zfd�dHdI�ZgdJdK� ZhdLdM� ZidNdO� Zjd�dQdR�Zkd�dSdT�ZldUdV� ZmdWdX� Znd�dYdZ�Zoepeqd[�Zrer�rPd\d]� Zsnd^d]� Zsd�d_d`�Ztd�dadb�Zudcdd� Zvdedf� Zwdgdh� Zxd�didj�Zyd�dkdl�Zzdmdn� Z{d�dodp�Z|dqdr� Z}dsdt� Z~dudv� Zdwdx� Z�dydz� Z�d�d{d|�Z�d}d~� Z�dd�� Z�d�d�� Z�d�d�� Z�e�� \Z�Z�d�Z�d�d�� Z�d�d�� Z�e�d��Z�G d�d�� d�eq�Z�G d�d�� d�e j��Z�d�d�� Z�d�d�� Z�e d�d�d�d�d�d�g�Z�d�d�d��Z�e d�d�d�d�g�Z�d�d�d��Z�d�d�� Z�d�d�d��Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�d��Z�d�d�� Z�e(�r�e5d�d�� �Z�e5d�d�� �Z�e�fd�d��Z�e#�rd�d�� Z�nd�d�� Z�d�d�� Z�zd d�l�m�Z� d d�l�m�Z� W n& e k �rd d�d�� Z�d�d�� Z�Y nX d�d�� Z�d�d�dÄZ�dS )�� N)� namedtuple)�datetime�timezone)�Decimal)�partial� partialmethod�wraps)�Real)�parse_qs�unquote� urlencode�urlsplit� urlunsplit)�BaseExceptionGroup)�PY37)�DEFAULT_MAX_VALUE_LENGTH�EndpointType)� TYPE_CHECKING)� FrameType� TracebackType)�Any�Callable�cast�ContextManager�Dict�Iterator�List�NoReturn�Optional�overload� ParamSpec�Set�Tuple�Type�TypeVar�Union)�Hub)�Event�ExcInfo�P�Ri� � zsentry_sdk.errorsz^[a-zA-Z0-9/+=]*$z [Filtered])�false�f�n�no�off�0)�true�t�y�yes�on�1F)�strictc C s@ | dk rt | ��� nd}|tkr$dS |tkr0dS |r8dS t| �S )z�Casts an ENV variable value to boolean using the constants defined above. In strict mode, it may return None if the value doesn't match any of the predefined values. NFT)�str�lower�FALSY_ENV_VALUES�TRUTHY_ENV_VALUES�bool)�valuer8 � normalized� r@ �>/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/utils.py�env_to_boolM s rB c C s t j| ddd��d�S )zCSerialize data into a compact JSON representation encoded as UTF-8.F)�,�:)� allow_nan� separators�utf-8)�json�dumps�encode)�datar@ r@ rA � json_dumps] s rL c C s� z|t tjjd��d} d }tjdks*tjdkrBt�� }| jtj O _tj dddg|tj| | d��� d � � �d �}W 5 Q R X W n tttfk r� Y d S X |S ) Nzw+�win32�cygwin�gitz rev-parse�HEAD)�startupinfo�stdout�stderr�stdinr rG )�open�os�path�devnull�sys�platform� subprocessZSTARTUPINFOZdwFlagsZSTARTF_USESHOWWINDOW�Popen�PIPE�communicate�strip�decode�OSError�IOError�FileNotFoundError)�nullrQ �revisionr@ r@ rA �get_git_revisionc s* �� ��rf c C sH t j�d�} | r| S t� } | r"| S dD ]}t j�|�} | r&| S q&dS )zTry to guess a default release.ZSENTRY_RELEASE)ZHEROKU_SLUG_COMMITZSOURCE_VERSIONZ!CODEBUILD_RESOLVED_SOURCE_VERSIONZCIRCLE_SHA1ZGAE_DEPLOYMENT_IDN)rV �environ�getrf )�release�varr@ r@ rA �get_default_release s rk c C sP ddddddddd d ddd dddddddg}|D ]}|| kr0d� |� S q0dS )zAReturn the SDK name including the name of the used web framework.�djangoZflaskZfastapiZbottleZfalconZquartZsanicZ starletteZlitestarZstarliteZchaliceZ serverlessZpyramid�tornadoZaiohttpZ aws_lambdaZgcpZbeamZasgiZwsgizsentry.python.{}z sentry.python)�format)Zinstalled_integrationsZframework_integrations�integrationr@ r@ rA �get_sdk_name� s2 �rp c @ s e Zd ZdZdd� Zdd� ZdS )�CaptureInternalExceptionr@ c C s | S �Nr@ ��selfr@ r@ rA � __enter__� s z"CaptureInternalException.__enter__c C s"