ž ­ÿf /c@s%dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z dd„Z gZ dd„Z dd„Zd d „Zd d „Zd d„Zddd„Zddd„ZGdd„dƒZeƒjZdddddd„ZdS(uš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. iNcCsdS(uAReturn a string that resets the CGI and browser to a known state.u' --> --> ((((u*/opt/alt/python33/lib64/python3.3/cgitb.pyureset#suresetcCs|rd|dSdSdS(Nuuu((utext((u*/opt/alt/python33/lib64/python3.3/cgitb.pyusmall.s usmallcCs|rd|dSdSdS(Nuu u((utext((u*/opt/alt/python33/lib64/python3.3/cgitb.pyustrong4s ustrongcCs|rd|dSdSdS(Nuuu((utext((u*/opt/alt/python33/lib64/python3.3/cgitb.pyugrey:s ugreycCsº||krd||fS||jkr:d|j|fSd|jkr°|jd}t|ƒtiƒkr‹||kr­d||fSq°t||ƒr°dt||ƒfSndtfS(u9Find the value for a given name in the given environment.ulocaluglobalu __builtins__ubuiltinN(u f_globalsutypeuhasattrugetattruNoneu __UNDEF__(unameuframeulocalsubuiltins((u*/opt/alt/python33/lib64/python3.3/cgitb.pyulookup@s   ulookupcCs2gdddtf\}}}}}xtj|ƒD]ö\}} } } } |tjkr\Pn|tjkrõ| tjkrõ|dkrÄ|tk ròt|| tƒ}|j || ||fƒqòq$t | ||ƒ\} }|j | | |fƒn/| dkr||d7}|}n d\}}| }q4W|S(uEScan one logical line of Python and look up values of variables used.uu.N(Nu( uNoneu __UNDEF__utokenizeugenerate_tokensuNEWLINEuNAMEukeywordukwlistugetattruappendulookup(ureaderuframeulocalsuvarsu lasttokenuparentuprefixuvalueuttypeutokenustartuendulineuwhere((u*/opt/alt/python33/lib64/python3.3/cgitb.pyuscanvarsPs"$%       uscanvarsic" sÈ|\}}}t|tƒr*|j}ndtjjƒddtj}tjtjƒƒ}dt j j dt t j j t|ƒƒƒdd|d|ƒd }d td d ƒd }g} tj||ƒ} xþ| D]ö\} ‰} } }}ˆr.tjjˆƒ‰dˆt j j ˆƒf}n d‰}tj| ƒ\}}}}d}| dkršdt | ƒtj||||ddd„ƒ}ni‰| g‡‡fdd†}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]É\}}} ||kréqÈnd||<| tk r€|d-kr"d |t |ƒ}n8|d!kr=t |ƒ}n|t |jd"ƒd.ƒ}|jd#|t j j| ƒfƒqÈ|j|d$ƒqÈW|jdttd%j|ƒƒƒƒ| jd&d'j|ƒƒqßWd(t t j j t|ƒƒƒt j j t|ƒƒfg}!xet |ƒD]W}|d)d…d*krEq#nt j jt!||ƒƒ} |!jd+||| fƒq#W|dj| ƒdj|!ƒd,t j j djt"j#|||ƒƒƒS(/u9Return a nice HTML document describing a given traceback.uPython iu: uu%su#ffffffu#6622aau
u‹

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

uu iu  u%su?uuin u formatvaluecSsdtjj|ƒS(Nu=(upydocuhtmlurepr(uvalue((u*/opt/alt/python33/lib64/python3.3/cgitb.pyusuhtml..c s<dˆ|d.readeru+%s%s %su u=>%s%su&%su  %s%su%siuglobalubuiltinu %s ulocalu.u %s = %su undefinedu, uF %s
u u

%s: %sNu_u
%s%s = %suî (uglobalubuiltiniÿÿÿÿ($u isinstanceutypeu__name__usysuversionusplitu executableutimeuctimeupydocuhtmluheadingustronguescapeustrusmalluinspectugetinnerframesuosupathuabspathu getargvaluesuformatargvaluesuscanvarsuNoneulenu preformatuappendugreyu __UNDEF__ureprujoinudirugetattru tracebackuformat_exception("ueinfoucontextuetypeuevalueuetbupyverudateuheaduindentuframesurecordsuframeulnumufunculinesuindexulinkuargsuvarargsuvarkwulocalsucallureaderuvarsurowsuiulineunumudoneudumpunameuwhereuvalueu exception((ufileu highlightu*/opt/alt/python33/lib64/python3.3/cgitb.pyuhtmles| "@      .       && uhtmlc sl|\}}}t|tƒr*|j}ndtjjƒddtj}tjtjƒƒ}dt |ƒ||fd}g}t j ||ƒ} x*| D]"\} ‰} } } }ˆrÍt j jˆƒpÐd‰t j| ƒ\}}}}d}| dkr/d| t j||||d d d „ƒ}ni‰| g‡‡fd d †}t|| |ƒ}dˆ|fg}|dk rÊ| |}x<| D]1}d|}|j||jƒƒ|d7}q’Wnig}}xµ|D]­\}}}||krÿqÞnd||<|tk rz|dkr.d|}n&|dkrT||jdƒd}n|jd|tjj|ƒfƒqÞ|j|dƒqÞW|jdj|ƒƒ|jddj|ƒƒqWdt |ƒt |ƒfg}xIt|ƒD];}tjjt||ƒƒ}|jdd ||fƒqïW|dj|ƒdj|ƒddjtj|||ƒƒS(!u:Return a plain text document describing a given traceback.uPython iu: u %s %s %s u… A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. u?uuin u formatvaluecSsdtjj|ƒS(Nu=(upydocutexturepr(uvalue((u*/opt/alt/python33/lib64/python3.3/cgitb.pyuÔsutext..c s<dˆ|d.readeru %s %su%5d iuglobaluglobal ulocalu.u%s = %su undefinedu u %s u%s: %su %s%s = %su iuc The above is a description of an error in a Python program. Here is the original traceback: %s Niÿÿÿÿu (u isinstanceutypeu__name__usysuversionusplitu executableutimeuctimeustruinspectugetinnerframesuosupathuabspathu getargvaluesuformatargvaluesuscanvarsuNoneuappendurstripu __UNDEF__upydocutextureprujoinudirugetattru tracebackuformat_exception( ueinfoucontextuetypeuevalueuetbupyverudateuheaduframesurecordsuframeulnumufunculinesuindexuargsuvarargsuvarkwulocalsucallureaderuvarsurowsuiulineunumudoneudumpunameuwhereuvalueu exception((ufileu highlightu*/opt/alt/python33/lib64/python3.3/cgitb.pyutext¿s^ "           &utextcBsP|EeZdZdZdd dd ddd„Zdd„Zd d d „Zd S( uHooku?A hook to replace sys.excepthook that shows tracebacks in HTML.iiuhtmlcCs:||_||_||_|p'tj|_||_dS(N(udisplayulogdirucontextusysustdoutufileuformat(uselfudisplayulogdirucontextufileuformat((u*/opt/alt/python33/lib64/python3.3/cgitb.pyu__init__s    u Hook.__init__cCs|j|||fƒdS(N(uhandle(uselfuetypeuevalueuetb((u*/opt/alt/python33/lib64/python3.3/cgitb.pyu__call__ su Hook.__call__c Csø|ptjƒ}|jdkr7|jjtƒƒn|jdkrLtpOt}d}y|||j ƒ}Wn&dj t j |Œƒ}d}YnX|jrö|rß|jddƒjddƒ}|jjd|dƒq|jj|d ƒn|jjd ƒ|jdk rØd d g|jdk}tjd |d|jƒ\}}y7tj|dƒ}|j|ƒ|jƒd|} Wnd|} YnX|jdkrÁ|jjd| ƒqØ|jj| d ƒny|jjƒWnYnXdS(Nuhtmluu&u&uu u u*

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

%s

FT(usysuexc_infouformatufileuwriteuresetuhtmlutextuFalseucontextujoinu tracebackuformat_exceptionuTrueudisplayureplaceulogdiruNoneutempfileumkstempuosufdopenucloseuflush( uselfuinfou formatteruplainudocusuffixufdupathufileumsg((u*/opt/alt/python33/lib64/python3.3/cgitb.pyuhandlesB  !  u Hook.handleN(u__name__u __module__u __qualname__u__doc__uNoneu__init__u__call__uhandle(u __locals__((u*/opt/alt/python33/lib64/python3.3/cgitb.pyuHooks   uHookic Cs(td|d|d|d|ƒt_dS(uInstall 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.udisplayulogdirucontextuformatN(uHookusysu excepthook(udisplayulogdirucontextuformat((u*/opt/alt/python33/lib64/python3.3/cgitb.pyuenable9suenable(u__doc__uinspectukeywordu linecacheuosupydocusysutempfileutimeutokenizeu tracebackuresetu __UNDEF__usmallustrongugreyulookupuscanvarsuhtmlutextuHookuhandleuhandleruNoneuenable(((u*/opt/alt/python33/lib64/python3.3/cgitb.pyus,                ZA8