usr/lib64/python2.7/cgitb.pyo000064400000027630147207517550011713 0ustar00 mfc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z dZ gZ dZdZdZdZdZd d Zd d Zd dd YZejZddd ddZdS(sMore comprehensive traceback formatting for Python scripts. To enable this module, do: import cgitb; cgitb.enable() at the top of your script. The optional arguments to enable() are: display - if true, tracebacks are displayed in the web browser logdir - if set, tracebacks are written to files in this directory context - number of lines of source code to show for each stack frame format - 'text' or 'html' controls the output format By default, tracebacks are displayed but not saved, the context is 5 lines and the output format is 'html' (for backwards compatibility with the original use of this module) Alternatively, if you have caught an exception and want cgitb to display it for you, call cgitb.handler(). The optional argument to handler() is a 3-item tuple (etype, evalue, etb) just like the value of sys.exc_info(). The default handler displays output as HTML. iNcCsdS(sAReturn a string that resets the CGI and browser to a known state.s' --> --> ((((s/usr/lib64/python2.7/cgitb.pytreset$scCs|rd|dSdSdS(Nsst((ttext((s/usr/lib64/python2.7/cgitb.pytsmall/s cCs|rd|dSdSdS(Nss R((R((s/usr/lib64/python2.7/cgitb.pytstrong5s cCs|rd|dSdSdS(NssR((R((s/usr/lib64/python2.7/cgitb.pytgrey;s cCs||krd||fS||jkr:d|j|fSd|jkr|jd}t|tikr||krd||fSqt||rdt||fSndtfS(s9Find the value for a given name in the given environment.tlocaltglobalt __builtins__tbuiltinN(t f_globalsttypethasattrtgetattrtNonet __UNDEF__(tnametframetlocalstbuiltins((s/usr/lib64/python2.7/cgitb.pytlookupAs   cCs2gdddtf\}}}}}xtj|D]\}} } } } |tjkr\Pn|tjkr| tjkr|dkr|tk rt|| t}|j || ||fqq$t | ||\} }|j | | |fn/| dkr||d7}|}n d\}}| }q4W|S(sEScan one logical line of Python and look up values of variables used.Rt.N(NR( RRttokenizetgenerate_tokenstNEWLINEtNAMEtkeywordtkwlistR tappendR(treaderRRtvarst lasttokentparenttprefixtvaluetttypettokentstarttendtlinetwhere((s/usr/lib64/python2.7/cgitb.pytscanvarsQs"$%       ic" s|\}}}t|tjkr0|j}ndtjjddtj}tj tj}dt j j dt t j jt|dd|d|d }d td d d }g} tj||} x| D]\} } } }}r4tjjdt j jf}n d}tj| \}}}}d}| dkrdt | tj||||dd}ni| gfd}t|| |}dd||fg}|d+k r| |}x|D]}td d tt|t|d }|krpd|t j j|f}|jd|n3d|t j j|f}|jdt||d7}qWnig}}x|D]\}}} ||krqnd||<| tk r|d,kr"d|t |}n8|dkr=t |}n|t |jd d!}|jd"|t j j| fq|j|d#qW|jdttd$j || jd%d&j |qWd't t j jt|t j jt|fg}!t!|t"rxbt#|D]Q}|d d(krNq2nt j jt$||} |!jd)||| fq2Wn|dj | dj |!d*t j jdj t%j&|||S(-s9Return a nice HTML document describing a given traceback.sPython is: ss%ss#ffffffs#6622aas
s

A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

ss is  s%st?Rsin t formatvaluecSsdtjj|S(Nt=(tpydocthtmltrepr(R"((s/usr/lib64/python2.7/cgitb.pytscs>d|d%s%s %ss s=>%s%ss&%ss  %s%ss%siRR s %s RRis %s = %ss undefineds, sF %s
s s

%s: %st_s
%s%s = %ss N(sglobalsbuiltin('R ttypest ClassTypet__name__tsystversiontsplitt executablettimetctimeR-R.theadingRtescapetstrRtinspecttgetinnerframestostpathtabspatht getargvaluestformatargvaluesR)Rtlent preformatRRRR/tjoint isinstancet BaseExceptiontdirR t tracebacktformat_exception("teinfotcontexttetypetevaluetetbtpyvertdatetheadtindenttframestrecordsRR3tfunctlinestindextlinktargstvarargstvarkwRtcallRRtrowstiR'tnumtdonetdumpRR(R"t exception((R4R5s/usr/lib64/python2.7/cgitb.pyR.fs~ "@      .       &&! c s~|\}}}t|tjkr0|j}ndtjjddtj}tj tj}dt |||fd}g}t j ||} x$| D]\} } } } }rt jjpdt j| \}}}}d}| dkr2d| t j||||d d }ni| gfd }t|| |}d |fg}|dk r| |}x<| D]1}d |}|j||j|d7}qWnig}}x|D]\}}}||krqnd||<|tk rz|dkr.d|}n&|dkrT||jdd}n|jd|tjj|fq|j|dqW|jdj||jddj|qWdt |t |fg}t|tr@xLt|D];}tjjt||}|jdd||fqWn|dj|dj|ddjtj |||S(s:Return a plain text document describing a given traceback.sPython is: s %s %s %s s A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. R*Rsin R+cSsdtjj|S(NR,(R-RR/(R"((s/usr/lib64/python2.7/cgitb.pyR0scs>d|dR?RBRCRDRERFRGRHRIR)RRtrstripRR-RR/RLRMRNROR RPRQ( RRRSRTRURVRWRXRYR[R\RR3R]R^R_RaRbRcRRdRRReRfR'RgRhRiRR(R"Rj((R4R5s/usr/lib64/python2.7/cgitb.pyRs` "           &!tHookcBs;eZdZddddddZdZddZRS(s?A hook to replace sys.excepthook that shows tracebacks in HTML.iiR.cCs:||_||_||_|p'tj|_||_dS(N(tdisplaytlogdirRSR:tstdoutR4tformat(tselfRnRoRSR4Rq((s/usr/lib64/python2.7/cgitb.pyt__init__s    cCs|j|||fdS(N(thandle(RrRTRURV((s/usr/lib64/python2.7/cgitb.pyt__call__sc Cs|ptj}|jdkr7|jjtn|jdkrLtpOt}t}y|||j }Wn%dj t j |}t }nX|jr|r|jddjdd}|jjd|dq|jj|d n|jjd |jdk rd d g|jdk}tjd |d|j\}}y7tj|d}|j||jd|} Wnd|} nX|jdkr|jjd| q|jj| d ny|jjWnnXdS(NR.Rt&s&ts s s*

A problem occurred in a Python script. s.txts.htmltsuffixROtws*%s contains the description of this error.s*Tried to save traceback to %s, but failed.s

%s

(R:texc_infoRqR4twriteRR.RtFalseRSRLRPRQtTrueRntreplaceRoRttempfiletmkstempREtfdopentclosetflush( Rrtinfot formattertplaintdocRxtfdRFR4tmsg((s/usr/lib64/python2.7/cgitb.pyRtsB  !  N(R9t __module__t__doc__RRsRuRt(((s/usr/lib64/python2.7/cgitb.pyRms    iR.c Cs(td|d|d|d|t_dS(sInstall an exception handler that formats tracebacks as HTML. The optional argument 'display' can be set to 0 to suppress sending the traceback to the browser, and 'logdir' can be set to a directory to cause tracebacks to be written to files there.RnRoRSRqN(RmR:t excepthook(RnRoRSRq((s/usr/lib64/python2.7/cgitb.pytenable<s((RRCRR1RER-R:RR>RRPR7RRRRRRR)R.RRmRtthandlerRR(((s/usr/lib64/python2.7/cgitb.pyts.                  [ B8