mf-ddlmZddlZddlZddlZddlZddlmZmZddlm Z m Z m Z m Z ddl mZddlmZddlmZerLddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZm Z ee!Z" ddl#m$Z$n#e%$r ddl&m$Z$YnwxYwGdde'Z(ddZ)Gdde(Z*Gdde(Z+dZ,dS))print_functionN)datetime timedelta)Dsnloggercapture_internal_exceptions json_dumps)BackgroundWorker)Envelope)MYPY)Any)Callable)Dict)Iterable)Optional)Tuple)Type)Union) PoolManager) ProxyManager)Event EndpointType) getproxiescBeZdZdZdZ d dZdZdZ d dZdZ dZ dS) TransportzWBaseclass for all transports. A transport is used to send an event to sentry. Nc~||_|r,|d$|drt|d|_dSd|_dS)Ndsn)optionsr parsed_dsn)selfrs K/opt/imunify360/venv/lib64/python3.11/site-packages/sentry_sdk/transport.py__init__zTransport.__init__/sG  #wu~1gen1!'%.11DOOO"DOOOct)zm This gets invoked with the event dictionary when an event should be sent to sentry. NotImplementedErrorr events r! capture_eventzTransport.capture_event9s"###r#ct)a$ Send an envelope to Sentry. Envelopes are a data container format that can hold any type of data submitted to Sentry. We use it for transactions and sessions, but regular "error" events should go through `capture_event` for backwards compat. r%)r envelopes r!capture_envelopezTransport.capture_envelopeCs"###r#cdS)z=Wait `timeout` seconds for the current events to be sent out.Nr timeoutcallbacks r!flushzTransport.flushQs  r#cdS)zForcefully kills the transport.Nr.r s r!killzTransport.killZs  r#cR |dS#t$rYdSwxYwN)r5 Exceptionr4s r!__del__zTransport.__del___s:  IIKKKKK    DD s  &&r7) __name__ __module__ __qualname____doc__rr"r)r,r2r5r9r.r#r!rr's J####$$$ $ $ $"       r#rc#pK|tj}|dD]} |dd\}}}|t t |z}|r|dpdD]}||fV r#t tf$rYwxYwdS)N,:seconds;r7)rutcnowsplitstriprint LookupError ValueError)headernowlimit retry_after categories_categorys r!_parse_rate_limitsrRgs {oc"" ).)<)>>*D  & & &$ #r#storec<|t|jjt|jd|jdt|j|||} |||j dkrn6|j dks |j dkr tj d|j |j | dS#| wxYw)N)z User-Agentz X-Sentry-AuthPOST)bodyrkrii,z%Unexpected status code: %s (body: %s))rmstrr^client to_headerrerequest get_api_urlrqrnrerrordataclose)r rurk endpoint_typerps r! _send_requestzHttpTransport._send_requests" !$*"344!$TZ%9%9%;%;!._disableds5%))&11BT>z0HttpTransport._send_envelope..s>   T-A-A!/-R-R    r#rrz(Sending envelope [%s] project:%s host:%szapplication/x-sentry-enveloperrr+)rkr)itemsrrrrserialize_intorrr descriptionrrrr)r r+rurs` r!_send_envelopezHttpTransport._send_envelopesR     ~   qqq~ 4z|| ]4c 2 2 2 'a  # #A & & & ' ' ' ' ' ' ' ' ' ' ' ' ' ' '*** 6  O & O     MMOO ?$*%    tsA33A7:A7c4dd|ptjdS)NrA CERT_REQUIRED) num_pools cert_reqsrY)certifiwhere)r rYs r!_get_pool_optionszHttpTransport._get_pool_optionss'( 3GMOO   r#ctd}|sdS|dD]M}|}|j|s|j|rdSNdS)NnoFr?T)rrlrFrGrendswithnetloc)r rno_proxyrs r! _in_no_proxyzHttpTransport._in_no_proxys<<##D)) 5NN3''  D::<->OL$NZ\\5E5Eg5N5NE N***Mx<#LJLL4D4DV4L4LE%%h//  /'6666 6&.... .r#cfjjfd}j|dS)Nc5t5dddn #1swxYwYddddS#1swxYwYdSr7)rr)r(hubr sr!send_event_wrapperz7HttpTransport.capture_event..send_event_wrapperBs , ,022,,$$U+++,,,,,,,,,,,,,,, , , , , , , , , , , , , , , , , , ,,A 5 A 9 A 9 A  AArgcurrentr\submit)r r(rrs`` @r!r)zHttpTransport.capture_event<sSl" , , , , , , , ./////r#cfjjfd}j|dS)Nc5t5dddn #1swxYwYddddS#1swxYwYdSr7)rr)r+rr sr!send_envelope_wrapperz=HttpTransport.capture_envelope..send_envelope_wrapperPs 2 202222''111222222222222222 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2rr)r r+rrs`` @r!r,zHttpTransport.capture_envelopeJsSl" 2 2 2 2 2 2 2 122222r#Ncttjd|dkr|j||dSdS)NzFlushing HTTP transportr)rrr\r2r/s r!r2zHttpTransport.flushXsC  ./// Q;; L  w 1 1 1 1 1 ;r#c`tjd|jdS)NzKilling HTTP transport)rrr\r5r4s r!r5zHttpTransport.killbs- -... r#)rrr7)r:r;r<r=r"rqrrrrrrrdr)r,r2r5r.r#r!rTrTvs%%2* ####J666:B      ///4 0 0 0 3 3 3"2222r#rTceZdZdZdZdS)_FunctionTransportcHt|||_dSr7)rr"_func)r funcs r!r"z_FunctionTransport.__init__is# 4    r#c0||dSr7)rr's r!r)z _FunctionTransport.capture_eventps 5tr#N)r:r;r<r"r)r.r#r!rrhs2r#rc|d}|t}nbt|tr|St|trt |tr|}nt |rt |S|dr ||SdS)N transportr)rT isinstancerr issubclasscallabler)r ref_transport transport_clss r!make_transportrxsK(M% M9 - -1 M4 ( (1Z y-Q-Q1% - 1!-000u~&}W%%% 4r#r7)- __future__rrr`rrrrsentry_sdk.utilsrrrr sentry_sdk.workerr sentry_sdk.enveloper sentry_sdk._typesr typingr rrrrrrrurllib3.poolmanagerrrrrrw DataCategoryurllib.requestr ImportErrorurllibobjectrrRrTrrr.r#r!rs%%%%%%  ((((((((QQQQQQQQQQQQ......((((((""""""!//////00000055555555C=L")))))))"""!!!!!!!!"========@    oooooIoood         s B B! B!