HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/thread-self/root/lib/python3/dist-packages/twisted/web/__pycache__/script.cpython-38.pyc
U

��W[q�@s�dZddlmZmZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZmZmZmZdZGd	d
�d
e�ZGdd�d�Ze�d
de�Zdd�Zdd�ZGdd�dej�ZGdd�dej�ZGdd�dej�Z dS)zH
I contain PythonScript, which is a very simple python script resource.
�)�division�absolute_importN)�	copyright)�_coerceToFilesystemEncoding)�execfile�
networkString�NativeStringIO�_PY3)�http�server�static�resource�utilz�<p>You forgot to assign to the variable "resource" in your script. For example:</p>
<pre>
# MyCoolWebApp.rpy

import mygreatresource

resource = mygreatresource.MyGreatResource()
</pre>
c@seZdZdZdS)�
AlreadyCachedzG
    This exception is raised when a path has already been cached.
    N)�__name__�
__module__�__qualname__�__doc__�rr�4/usr/lib/python3/dist-packages/twisted/web/script.pyrsrc@s$eZdZdd�Zdd�Zdd�ZdS)�CacheScannercCs||_||_d|_dS)Nr)�path�registry�doCache��selfrrrrr�__init__#szCacheScanner.__init__cCs*|j�|j�}|dk	rt|��|��dS�N)rZ
getCachedPathrr�recache)r�crrr�cache(szCacheScanner.cachecCs
d|_dS)N�)r)rrrrr.szCacheScanner.recacheN)rrrrr rrrrrr"sr���Whoops! Internal Errorc
Cs�t||�}td|�t||j|jd�}zt|||�Wn0tk
rd}z|jdWY�Sd}~XYnX|d}|jr�|tk	r�|�	||�|S)z�
    I am a normal py file which must define a 'resource' global, which should
    be an instance of (a subclass of) web.resource.Resource; it will be
    renderred.
    �)�__file__r
rr rrNr
)
rr�noRsrcr rrr�argsrZ	cachePath)rrZcs�globZacZrsrcrrr�ResourceScript3s
� r)c	Cshddlm}td|�t�ddt�|d�}t|��}|�||�}W5QRXt|dd�}t	|||�|d	S)
Nr)�ptl_compiler$r"r#)r%r
rz<source>�execr
)
Zquixoter*rr
�	ErrorPage�
rpyNoResource�openZcompile_template�compile�eval)rrr*r(�f�e�coderrr�ResourceTemplateJs��
r4c@s&eZdZddd�Zdd�Zdd�ZdS)	�ResourceScriptWrapperNcCs$tj�|�||_|pt��|_dSr�r
�ResourcerrrZRegistryrrrrrr\szResourceScriptWrapper.__init__cCst|j|j�}|�|�Sr)r)rr�render)r�request�resrrrr8aszResourceScriptWrapper.rendercCst|j|j�}|�||�Sr)r)rr�getChildWithDefault)rrr9r:rrrr;esz)ResourceScriptWrapper.getChildWithDefault)N)rrrrr8r;rrrrr5Zs
r5c@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�ResourceScriptDirectorya
    L{ResourceScriptDirectory} is a resource which serves scripts from a
    filesystem directory.  File children of a L{ResourceScriptDirectory} will
    be served using L{ResourceScript}.  Directory children will be served using
    another L{ResourceScriptDirectory}.

    @ivar path: A C{str} giving the filesystem path in which children will be
        looked up.

    @ivar registry: A L{static.Registry} instance which will be used to decide
        how to interpret scripts found as children of this resource.
    NcCs$tj�|�||_|pt��|_dSrr6)r�pathnamerrrrrxsz ResourceScriptDirectory.__init__cCsHtj�|j|�}tj�|�r(t||j�Stj�|�r@t||j�St�	�Sr)
�osr�join�isdirr<r�existsr)r
�
NoResource)rrr9�fnrrr�getChild}sz ResourceScriptDirectory.getChildcCst���|�Sr)r
rBr8)rr9rrrr8�szResourceScriptDirectory.render)N)rrrrrrDr8rrrrr<ks
	r<c@s$eZdZdZdZdd�Zdd�ZdS)�PythonScriptz�
    I am an extremely simple dynamic resource; an embedded python script.

    This will execute a file (usually of the extension '.epy') as Python code,
    internal to the webserver.
    TcCs||_||_dS)z3
        Initialize me with a script name.
        N)�filenamer)rrFrrrrr�szPythonScript.__init__c
Cs�|�dtdtj��|td|j�|jd�}zt|j||�Wn�tk
r�}z0|j	dkr||�
tj�|�
t�d��|��W5d}~XYnDt�}tj|d�t�|���}tr�|�d	�}|�
|�YnX|��tjS)
a4
        Render me to a web client.

        Load my file, execute it in a special namespace (with 'request' and
        '__file__' global vars) and finish the request.  Output to the web-page
        will NOT be handled with print - standard output goes to the log - but
        with request.write.
        sx-powered-byz
Twisted/%sr$)r9r%r�zFile not found.N)�file�utf8)Z	setHeaderrr�versionrrFrr�IOError�errnoZsetResponseCoder
Z	NOT_FOUND�writer
rBr8r�	traceback�	print_excrZ_PRE�getvaluer	�encodeZfinishrZNOT_DONE_YET)rr9�	namespacer2�io�outputrrrr8�s(	
�
&
zPythonScript.renderN)rrrrZisLeafrr8rrrrrE�srE)!rZ
__future__rrr>rNZtwistedrZtwisted.python.filepathrZtwisted.python.compatrrrr	Ztwisted.webr
rrr
rr-�	Exceptionrrr,r&r)r4r7r5r<rErrrr�<module>s