Qf0 dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Ze jeddZgZdZdZd Zd Zd Zdd Z dd ZGddZej4ZddZy)aMore 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. N)escape) )removecy)zAReturn a string that resets the CGI and browser to a known state.a' --> --> r,/opt/alt/python312/lib64/python3.12/cgitb.pyresetr (s Hr c|rd|zdzSy)Nzzrtexts r smallr3s 4*,,r c|rd|zdzSy)Nzz r rrs r strongr9s D ;..r c|rd|zdzSy)Nzzr rrs r greyr?s '$.::r c||vrd||fS||jvrd|j|fSd|jvrL|jd}t|tr||vrd||fSdt fSt||rdt ||fSdt fS)z9Find the value for a given name in the given environment.localglobal __builtins__builtinN) f_globals isinstancedicthasattrgetattr __UNDEF__)nameframelocalsbuiltinss r lookupr$Es v~t $$ u...(??>2 h %x (4.00 ?x& '(D"999 ?r cgdddtf\}}}}}tj|D]\}} } } } |tjk(r|S|tjk(rm| t j vr[|dk(r1|turct|| t}|j|| z||fn:t| ||\} }|j| | |fn| dk(r ||dzz }|}nd\}}| }|S)zEScan one logical line of Python and look up values of variables used.Nr .)Nr ) rtokenizegenerate_tokensNEWLINENAMEkeywordkwlistrappendr$)readerr!r"vars lasttokenparentprefixvaluettypetokenstartendlinewheres r scanvarsr:Us-/tR-J*D)VVU*2*B*B6*J&ueS$ H$$ $e K HMM !e7>>&AC*#FE9=EKK% ?@%eUF; u UE512 c\ i#o %FF%NFF +K Kr c Z "#|\}}}t|tr |j}dtjj dzdztj z}tjtj}dtt|d|d|d}dtd zd z}g} tj||} | D]\} "} } }}"rFtjj!""d "d t"j$j'"d }ndx"}tj(| \}}}}d}| dk7rNdt+t"j$j'| z}| dk7r|tj,||||dz }i#| gf"#fd }t/|| |}dd|d|dg}|| |z }|D]}tddt1t|z zt|zdz}|#vr:d|t"j$j3|d}|j5d|znBd|t"j$j3|d}|j5d t7|z|d!z }ig}}|D]\}}} ||vr d!||<| t8ur{|d"vrd#|zt+|z}n1|d$k(r t+|}n |t+|j d%d&z}|j5|d't"j$j;| |j5|d(z|j5d tt7d)j=|z| j5d*d+j=|zd,t+t"j$j't|dt"j$j't|g}!t?|D]M}|dd!d-k(r t"j$j;tA||} |!j5d.||d/| O|dj=| zdj=|!zd0t"j$j'dj=tCjD|||zzS)1z9Return a nice HTML document describing a given traceback.Python r: z
 
 
zo
z
z

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

zz     z  zz?r in cFdtjj|zSN=)pydochtmlreprr3s r zhtml..cEJJOOE4J.Jr  formatvaluecd|d<tj|d|dxxdz cc<S#|dxxdz cc<wxYwNr linecachegetlinelnumfile highlights r r.zhtml..reader@!"Id1g !))$Q8!W\WT!W\W0?zz  z Nz z =>zz&%sz  z%srN)rrz %s rr&z = z undefinedz, zF %s
 z

_z
z = z )#rtype__name__sysversionsplit executabletimectime html_escapestrrinspectgetinnerframesospathabspathrDrEr getargvaluesrformatargvaluesr:len preformatr-rrrFjoindirr tracebackformat_exception)$einfocontextetypeevalueetbpyverdateheadindentframesrecordsr!rSfunclinesindexlinkargsvarargsvarkwr"callr.r/rowsir8numdonedumpr r9r3 exceptionrTrUs$ @@r rErEjsUE63%  ))+A. . 5 FE ::diik "D s5z*+,//4gT$@H KDeL) )M 9F F$$S'2G18-tT4 77??4(D379J9J49PQD D4'.';';E'B$guf 3;6%**"3"3D"9::Dz!//guf JLL  "v.%dD23  u AH#c!f+ 6Q?@8K >36 8L8LT8RSDKK H4 OP";>uzz?S?STX?YZDKK 6d CDQd"& D%t|XDJI%11*U2fTlBDg%!$>D dEJJOOE4JKL D#889#' *U4 $3H-IIJ  $  !g29n!'uzz'8'8U'D E % 1 1#f+ >@AIF  8s?H  56FD%HI "''&/ !BGGI$6 6 : jj ''),,UFC@ AC :C C Cr c : !|\}}}t|tr |j}dtjj dzdztj z}tjtj}t|d|d|ddz}g}tj||} | D]\} } } } } xrtjj xsd tj| \}}}}d}| dk7r(d| z}| d k7r|tj ||||d z }i!| gf !fd }t#|| |}d d |g}|8| |z }| D].}d|z}|j%||j'z|dz }0ig}}|D]\}}}||vr d||<|t(ur[|dk(rd|z}n|dk7r||j ddz}|j%|dt*j,j/|t|j%|dz|j%dj1||j%ddj1|zt|dt|g}t3|D]D}t*j,j/t5||}|j%dd|d|F|dj1|zdj1|zddj1t7j8|||zzS)z:Return a plain text document describing a given traceback.r<rr=r[z 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>r r?r@cFdtjj|zSrB)rDrrFrGs r rHztext..rIr rJcd|d<tj|d|dxxdz cc<S#|dxxdz cc<wxYwrMrOrRs r r.ztext..readerrVrWrXz%5d rNrzglobal rr&rZz = z undefinedz %s z zc The above is a description of an error in a Python program. Here is the original traceback: %s )rr]r^r_r`rarbrcrdrfrgrhrirjrkrlrmr:r-rstriprrDrrFrprqrrrrs)"rtrurvrwrxryrzr{r}r~r!rSrrrrrrr"rr.r/rrr8rrrr r9r3rrTrUs" @@r rrsE63%  ))+A. . 5 FE ::diik "D Z 59 D F$$S'2G18-tT4--4'.';';E'B$guf 3;4 "''&/ !BGGI$6 6:  ggi((<= :> >>r c*eZdZdZ ddZdZddZy)Hookz?A hook to replace sys.excepthook that shows tracebacks in HTML.Ncn||_||_||_|xstj|_||_yN)displaylogdirrur_stdoutrTformat)selfrrrurTrs r __init__z Hook.__init__s.   &CJJ  r c,|j|||fyr)handle)rrvrwrxs r __call__z Hook.__call__s UFC()r cj|xstj}|jdk(r#|jj t |jdk(xrt xst}d} |||j}|jrb|rAtj j|}|jj d|zdzn:|jj |dzn|jj d|jd d g|jdk(}t!j"||j \}} t%j&|d 5}|j |dddd |z} |jdk(r|jj d| zn|jj | dz |jj)y#djtj|}d}YxYw#1swYxYw#d|z} YxYw#YyxYw)NrEFr Tz

z
r[z*

A problem occurred in a Python script. z.txtz.html)suffixrqwz*%s contains the description of this error.z*Tried to save traceback to %s, but failed.z

%s

)r_exc_inforrTwriter rErrurprrrsrrDrrtempfilemkstemprifdopenflush) rinfo formatterplaindocrfdrjrTmsgs r rz Hook.handles%s||~ ;;& IIOOEG $[[&(2d:d  D$,,/C <<jj'', # :; d + IIOOI J ;; "g&t{{F':;F!))T[[IJR JYYr3'4JJsO(BTI{{f$   34 d +  IIOO ; '')44d;rs.  &Xg.H      *_CB@>D55n &--:r