Your IP : 18.191.171.10


Current Path : /opt/alt/python27/lib/python2.7/site-packages/raven/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyc

�
��Yc@@s�ddlmZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZddlm
Z
gZiZejd�Zd�Zdefd	��YZd
efd��YZed�Zd
�Zdddddddd�Zd�Zdd�Zd�Ze
d��Zdd�Zd�Z d�Z!iZ"d�Z#e#d�d��Z$e#d�d��Z%d�Z&ddl'Z(dS(i(tabsolute_importN(tFunctionType(t	iteritemstget_codet	text_typetstring_types(toncetravencC@sb|d|dkoa|d|dkoa|d|dkoa|d|dkoa|d|dkS(Nttypetleveltmessagetcategorytdata((tatb((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytevent_payload_considered_equals
tBreadcrumbBuffercB@sDeZdd�Zdddddddd�Zd�Zd�ZRS(idcC@sg|_||_dS(N(tbuffertlimit(tselfR((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt__init__s	cC@s�|p|p|s!td��n|dkr<tj�}n|jji|pQdd6|d6|d6|d6|d6|d6|f�|j|j4dS(	Ns6You must pass either `message`, `data`, or `processor`tdefaultRt	timestampR	R
RR(t
ValueErrortNonettimeRtappendR(RRR	R
RRRt	processor((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytrecord#s

cC@s|j2dS(N(R(R((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytclear4scC@s�g}x�t|j�D]�\}\}}|dk	ry||�Wn$tk
rhtjd�d}nX|df|j|<n|dk	r|s�t|d|�r|j|�qqW|S(Ns&Failed to process breadcrumbs. Ignoredi����(t	enumerateRRt	Exceptiontloggert	exceptionRR(RtrvtidxtpayloadR((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt
get_buffer7s"


N(t__name__t
__module__RRRRR%(((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyRs
		tBlackholeBreadcrumbBuffercB@seZd�ZRS(cO@sdS(N((Rtargstkwargs((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyRHs(R&R'R(((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyR(GscC@s|r
t�St�S(N(RR((tenabled((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytmake_bufferLscO@s||d<t||�S(NR(R(RR)R*((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytrecord_breadcrumbRs
c	C@s[|dkrtj�}nx9tjj�D](}|jj|||||||�q+WdS(s�Records a breadcrumb for all active clients.  This is what integration
    code should use rather than invoking the `captureBreadcrumb` method
    on a specific client.
    N(RRRtcontexttget_active_contextstbreadcrumbsR(R
RR	RRRRtctx((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyRXs
c@s�x0tD](}|������}|rdSqWtj�j�}|dk	rv|������}|rvdSn�����fd�}td|�dS(Nc@s��}y#t��}�r(��}nWntk
r<nX�jdd�|ji|d6�jd6tj��j�d6�d6�dS(Ntexc_infoR
RR	R(	RRtpopRtupdatetnametloggingtgetLevelNametlower(Rt
formatted_msg(R)R*R	R tmsg(sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyRqs
	
R(tspecial_logging_handlerstspecial_logger_handlerstgetR5RR(R R	R:R)R*thandlerR"R((R)R*R	R R:sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt_record_log_breadcrumbes
c	C@snt|t�s|j}n|}t|dt�r7dS|dkrRd}d}nd}d|}t|�}tj}|dkr�t	j
jtjj
j�}ni}ttdid|jdd	6|jd
6dj|�d6|d
6|d6|d�tj|�|d|t�}|j|_|jt|�jksAt�|j|jk|j|jkt|_|S(Nt__patched_for_raven__R	R:s
level, msgs%d, msgs%(offset)sif 1:
    def factory(original, record_crumb):
        def %(name)s(self, %(args)s, *args, **kwargs):
            record_crumb(self, %(fwd)s, *args, **kwargs)
            return original(self, %(args)s, *args, **kwargs)
        return %(name)s
    
s
itoffsetR5s, R)tfwdtexectfactory(R	R:(R:(t
isinstanceRtim_functgetattrtFalseRRR6t_srcfiletostpathtnormpathtcurrentframet__code__tco_filenametevaltcompiletco_firstlinenoR&tjoint__dict__R?t__doc__tAssertionErrorR'tTrueR@(	tmethR	tfuncR)RBtcodetlogging_srcfiletnstnew_func((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt_wrap_logging_method�s>	
		
	cC@s�tj}itjd6tjd6tjd6tjd6tjd6tjd6tjd6tjd6}xEt	|�D]7\}}t
t||�|�}ttj||�qlWt
tjj
�tj_
dS(	NtdebugtinfotwarningtwarnterrorR!tcriticaltfatal(R6tLoggertDEBUGtINFOtWARNINGtWARNtERRORtCRITICALtFATALRR^RGtsetattrtlog(tclstmethodstmethod_nameR	R]((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt
_patch_logger�s 	







cC@st�dS(sXInstalls the logging hook if it was not installed yet.  Otherwise
    does nothing.
    N(Rs(((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytinstall_logging_hook�sc@s �fd�}t||�dS(s�Ignores a logger for the regular breadcrumb code.  This is useful
    for framework integration code where some log messages should be
    specially handled.
    c@s �dk	r|�krtStS(N(RRHRW(R R	R:R)R*(tallow_level(sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyR>�sN(tregister_special_log_handler(tname_or_loggerRuR>((RusB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt
ignore_logger�scC@s/t|t�r|}n	|j}|t|<dS(sRegisters a callback for log handling.  The callback is invoked
    with give arguments: `logger`, `level`, `msg`, `args` and `kwargs`
    which are the values passed to the logging system.  If the callback
    returns `True` the default handling is disabled.
    N(RERR5R<(RwtcallbackR5((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyRv�s		cC@stj|�dS(sRegisters a callback for log handling.  The callback is invoked
    with give arguments: `logger`, `level`, `msg`, `args` and `kwargs`
    which are the values passed to the logging system.  If the callback
    returns `True` the default handling is disabled.
    N(R;R(Ry((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytregister_logging_handler
sc@s�fd�}|S(Nc@st|�}|t�<|S(N(Rthooked_libraries(tf(R5(sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt	decorators
((R5R}((R5sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytlibraryhookstrequestsc@sayddlm}Wntk
r(dSX|j��fd�}||_tddtj�dS(Ni(tSessionc@sW�fd�}y�|�||�}Wntk
rH|d��nX||�|S(Nc	@s]tdddddi�jd6�jd6|r8|jp;dd6|rN|jpQdd	6�dS(
NRthttpRRRturltmethodtstatus_codetreason(RR�R�R�RR�(tresponse(trequest(sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt_record_request(s


(RR(RR�R)R*R�tresp(t	real_send(R�sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytsend's


s(requests.packages.urllib3.connectionpoolRu(trequests.sessionsR�tImportErrorR�RxR6Ri(R�R�((R�sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt_hook_requestss
			thttplibc@s~yddlm}Wn!tk
r7ddlm}nX|j�|j��fd�}�fd�}||_||_dS(Ni(tHTTPConnectionc@sui|_�|j�|j�|j�������fd�}tddddd|��|��||�S(Nc@s��}|jd�sVd�dkr*dp-d���krFd�pId�f}ni|d	6�d
6|d<|dj��|S(
Nshttp://shttps://s%s://%s%s%si�thttpsR�s:%stR�R�R(shttp://shttps://(t
startswithR4(Rtreal_url(tdefault_portthostR�tporttstatusR�(sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyRNs
RR�RRR(t_raven_status_dictR�R�R�R(RR�R�R)R*R(treal_putrequest(R�R�R�R�R�R�sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt
putrequestHs
			c@s]�|||�}t|dd�}|dk	rYd|krY|j|d<|j|d<n|S(NR�R�R�(RGRR�R�(RR)R*R"R�(treal_getresponse(sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pytgetresponse`s
(R�R�R�thttp.clientR�R�(R�R�R�((R�R�sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt_install_httplib>s
			cC@se|dkrtj�}nxC|D];}tj|�}|dkrVtd|��n|�q"WdS(NsUnknown library %r for hooking(RR{tkeysR=tRuntimeError(t	librariestlibRY((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pythook_librariesls
()t
__future__RRJRR6ttypesRtraven.utils.compatRRRRtraven.utilsRR;R<t	getLoggerR RtobjectRR(RWR,R-RRR?R^RsRtRxRvRzR{R~R�R�R�t
raven.contextR(((sB/opt/alt/python27/lib/python2.7/site-packages/raven/breadcrumbs.pyt<module>s:"	
*		&F	
	
			 .	

?>