Ñò §ÚêLc@sªdZdZdZddkZd„ZgZd„Zd„Zd„Zd „Z d „Z d d „Z d d „Z ddd„ƒYZ e ƒiZddd dd„ZdS(s™More 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. s Ka-Ping Yees$Revision: 83564 $iÿÿÿÿNcCsdS(sAReturn a string that resets the CGI and browser to a known state.s' --> --> ((((s/usr/lib64/python2.6/cgitb.pytresetscCs|o d|dSdSdS(Nsst((ttext((s/usr/lib64/python2.6/cgitb.pytsmall)s cCs|o d|dSdSdS(Nss R((R((s/usr/lib64/python2.6/cgitb.pytstrong/s cCs|o d|dSdSdS(NssR((R((s/usr/lib64/python2.6/cgitb.pytgrey5s cCsÆ||jod||fS||ijod|i|fSd|ijon|id}t|ƒthƒjo ||jod||fSq¼t||ƒodt||ƒfSndtfS(s9Find the value for a given name in the given environment.tlocaltglobalt __builtins__tbuiltinN(t f_globalsttypethasattrtgetattrtNonet __UNDEF__(tnametframetlocalstbuiltins((s/usr/lib64/python2.6/cgitb.pytlookup;s   cCsUddk}ddk}gdddtf\}}}}} x|i|ƒD]\} } } } }| |ijoPn| |ijo| |ijo€|djoA|tj o0t|| tƒ} |i || || fƒqqGt | ||ƒ\}} |i | || fƒn2| djo||d7}| }n d\}}| }qLW|S(sEScan one logical line of Python and look up values of variables used.iÿÿÿÿNRt.(NR( ttokenizetkeywordRRtgenerate_tokenstNEWLINEtNAMEtkwlistR tappendR(treaderRRRRtvarst lasttokentparenttprefixtvaluetttypettokentstarttendtlinetwhere((s/usr/lib64/python2.6/cgitb.pytscanvarsKs&$   "    ic's7ddk}ddk}ddk}ddk}ddk‰ddk}ddk‰|\}}} t|ƒ|ijo |i }ndt i i ƒddt i } |i|iƒƒ} dˆiidtˆiit|ƒƒƒdd | d | ƒd } d td dƒd} g}|i| |ƒ}xõ|D]í\}‰}}}}ˆo2|iiˆƒ‰dˆˆiiˆƒf}n d‰}|i|ƒ\}}}}d}|djo9dt|ƒ|i||||d‡fd†ƒ}nh‰|g‡‡‡fd†}t|||ƒ}dd||fg}|dj o¬||}xŸ|D]“}td dtt|ƒƒt|ƒƒd } d| ˆii|ƒf}|ˆjo|id|ƒn|idt|ƒƒ|d7}qdWnhg}!}"xÙ|D]Ñ\}#}$}%|#|!joqnd|!|#<|%t j o†|$d+jod|$t|#ƒ}#n;|$d jot|#ƒ}#n|$t|#i d!ƒdƒ}#|"id"|#ˆii!|%ƒfƒq|"i|#d#ƒqW|idttd$i"|"ƒƒƒƒ|id%d&i"|ƒƒq;Wd'tˆiit|ƒƒƒˆiit|ƒƒfg}&t#|t$ƒohxet%|ƒD]S}#|#d d(joq†nˆii!t&||#ƒƒ}%|&id)| |#|%fƒq†Wnddk}| di"|ƒdi"|&ƒd*ˆiidi"|i'||| ƒƒƒS(,s9Return a nice HTML document describing a given traceback.iÿÿÿÿNsPython 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 formatvaluecsdˆii|ƒS(t=(thtmltrepr(R"(tpydoc(s/usr/lib64/python2.6/cgitb.pyt~scs>dˆ|d%s%s %ss s %s%ss&%ss%siRR s %s RRs %s = %ss undefineds, sF %s
s s

%s: %st_s
%s%s = %ssî (sglobalsbuiltin((tosttypesttimet tracebackR5tinspectR/R t ClassTypet__name__tsystversiontsplitt executabletctimeR-theadingRtescapetstrRtgetinnerframestpathtabspatht getargvaluestformatargvaluesR)Rtlent preformatRRRR.tjoint isinstancet BaseExceptiontdirR tformat_exception('teinfotcontextR7R8R9R:R;tetypetevaluetetbtpyvertdatetheadtindenttframestrecordsRR2tfunctlinestindextlinktargstvarargstvarkwRtcallRRtrowstiR'tnumtdonetdumpRR(R"t exception((R4R/R5R3s/usr/lib64/python2.6/cgitb.pyR-asˆT "@      .       '& "  c%sùddk}ddk}ddk}ddk}ddk‰ddk}ddk‰|\}}} t|ƒ|ijo |i }ndt i i ƒddt i } |i|iƒƒ} dt|ƒ| | fd} g} |i| |ƒ}x;|D]3\}‰}}}}ˆo|iiˆƒpd‰|i|ƒ\}}}}d }|djo3d ||i||||d ‡fd †ƒ}nh‰|g‡‡‡fd †}t|||ƒ}dˆ|fg}|dj oJ||}x=|D]1}d|}|i||iƒƒ|d7}qöWnhg}} x½|D]µ\}!}"}#|!|joqCnd||!<|#tj oj|"djod|!}!n)|"djo|"|!i dƒd}!n| id|!ˆii|#ƒfƒqC| i|!dƒqCW|idi| ƒƒ| iddi|ƒƒqùWdt|ƒt|ƒfg}$t|tƒoPxMt|ƒD];}!ˆiit ||!ƒƒ}#|$idd|!|#fƒqlWnddk}| d i| ƒd i|$ƒdd i|i!||| ƒƒS(s:Return a plain text document describing a given traceback.iÿÿÿÿNsPython 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+csdˆii|ƒS(R,(RR.(R"(R/(s/usr/lib64/python2.6/cgitb.pyR0Óscs>dˆ|dR?R@RARBRERFRGRHRIRJR)RRtrstripRRR.RMRNRORPR RQ(%RRRSR7R8R9R:R;RTRURVRWRXRYR[R\RR2R]R^R_RaRbRcRRdRRReRfR'RgRhRiRR(R"Rj((R4R/R5R3s/usr/lib64/python2.6/cgitb.pyR½slT "           ' " tHookcBs;eZdZdddddd„Zd„Zdd„ZRS(s?A hook to replace sys.excepthook that shows tracebacks in HTML.iiR-cCs;||_||_||_|pti|_||_dS(N(tdisplaytlogdirRSR>tstdoutR4tformat(tselfRnRoRSR4Rq((s/usr/lib64/python2.6/cgitb.pyt__init__s    cCs|i|||fƒdS(N(thandle(RrRTRURV((s/usr/lib64/python2.6/cgitb.pyt__call__ sc Csþ|p tiƒ}|idjo|iitƒƒn|idjotpt}t}y|||i ƒ}Wn1ddk }di |i |Œƒ}t }nX|ioY|o:|iddƒiddƒ}|iid|d ƒq|ii|d ƒn|iid ƒ|idj oµddk}ddk}d d g|idj}|id|d|iƒ\} } y7|i| dƒ} | i|ƒ| iƒd| } Wnd| } nX|ii| d ƒny|iiƒWnnXdS(NR-iÿÿÿÿRt&s&ts s s*

A problem occurred in a Python script. s.txts.htmltsuffixRPtws.

%s contains the description of this error.s.

Tried to save traceback to %s, but failed.(R>texc_infoRqR4twriteRR-RtFalseRSR:RMRQtTrueRntreplaceRoRR7ttempfiletmkstemptfdopentclosetflush( Rrtinfot formattertplaintdocR:R7RRxtfdRGR4tmsg((s/usr/lib64/python2.6/cgitb.pyRtsB   !  N(R=t __module__t__doc__RRsRuRt(((s/usr/lib64/python2.6/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.6/cgitb.pytenable7s((R‹t __author__t __version__R>RRRRRRR)R-RRmRtthandlerRR(((s/usr/lib64/python2.6/cgitb.pyts        \ D5