σ ¬PrOc@@sRddlmZddlZddlmZddlZdefd„ƒYZdS(i(tabsolute_importN(tStringIOtCgitbMiddlewarecB@s>eZdZedddd„Zd„Zd„Zd„ZRS(sωForked from paste.cgitb_catcher. If bazjunk.catch_errors is False in environ, display a HTML error page instead, generated by a passed-in callable, unless the response has already started. Fix handling of GeneratorExit/.close()ithtmlcC@s@||_||_||_||_t|ƒ|_||_dS(N(tapptgen_htmltdisplaytlogdirtinttcontexttformat(tselfRRRRR R ((sa/afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/cgitb.pyt__init__s     cC@s₯y&|j||ƒ}|j||ƒSWnxd|kr>‚ntjƒ}|ddg|ƒ|jdd„ƒ|ƒr|j||ƒ}n |jƒ}|gSXdS(Nsbazjunk.throw_errorss500 Internal Server Errors content-types text/htmlsbazjunk.catch_errorscS@stS(N(tFalse(te((sa/afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/cgitb.pyt+s(s content-types text/html(Rt catching_itertsystexc_infotgettexception_handlerR(R tenvirontstart_responsetapp_iterRtresponse((sa/afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/cgitb.pyt__call__s    cc@s|st‚nt}y<x|D] }|VqWt|dƒrPt}|jƒnWnΐtk r‡| rt|dƒr|jƒqnd|krœ‚n|jtjƒ|ƒ}| r t|dƒr y|jƒWq |jtjƒ|ƒ}|d|7}q Xn|VnXdS(Ntclosesbazjunk.throw_errorss$
Error in .close():
%s( t StopIterationR thasattrtTrueRt GeneratorExitRRR(R RRterror_on_closetvRtclose_response((sa/afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/cgitb.pyR1s4     c C@st|jdd„ƒ|ƒs!‚ntƒ}tjd|d|jd|jd|jd|jƒ}||Œ|jƒS(Nsbazjunk.catch_errorscS@stS(N(R (R((sa/afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/cgitb.pyRNstfileRRR R ( RRtcgitbtHookRRR R tgetvalue(R RRt dummy_filethook((sa/afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/cgitb.pyRMs      N( t__name__t __module__t__doc__RtNoneR RRR(((sa/afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/cgitb.pyR s   (t __future__RR#t cStringIORRtobjectR(((sa/afs/athena.mit.edu/user/x/a/xavid/.local/lib/python2.7/site-packages/bazjunk/middleware/cgitb.pyts