403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.15.7.155
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/beaker/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/beaker/__pycache__/container.cpython-37.pyc
B

��[^�@s�dZddlZddlmZmZmZmZmZddlm	Z	ddl
Z
ddlZddlZddl
mZmZddlmZmZmZmZmZddd	d
ddd
dddddgZe
�d�Ze�e
j�r�ejZndd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd
�d
e �Z!Gdd�de�Z"Gdd�de�Z#iZ$e%Z&Gdd�de'�Z(ee(�Gd d�de��Z)Gd!d�de)�Z*Gd"d
�d
e)�Z+Gd#d�de)�Z,e,Z-dS)$zContainer and Namespace classes�N�)�pickle�anydbm�
add_metaclass�PYVER�unicode_text)�CreationAbortedError�MissingCacheParameter)�
_threading�file_synchronizer�mutex_synchronizer�NameLock�null_synchronizer�Value�	Container�ContainerContext�MemoryContainer�DBMContainer�NamespaceManager�MemoryNamespaceManager�DBMNamespaceManager�
FileContainer�OpenResourceNamespaceManager�FileNamespaceManagerrzbeaker.containercGsdS)N�)�message�argsrr�A/opt/alt/python37/lib/python3.7/site-packages/beaker/container.py�debugsrc@s�eZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
d%dd�Zdd�Zdd�Z
dd�Zdd�Zd&dd�Zdd�Zdd �Zd!d"�Zd#d$�ZdS)'raHHandles dictionary operations and locking for a namespace of
    values.

    :class:`.NamespaceManager` provides a dictionary-like interface,
    implementing ``__getitem__()``, ``__setitem__()``, and
    ``__contains__()``, as well as functions related to lock
    acquisition.

    The implementation for setting and retrieving the namespace data is
    handled by subclasses.

    NamespaceManager may be used alone, or may be accessed by
    one or more :class:`.Value` objects.  :class:`.Value` objects provide per-key
    services like expiration times and automatic recreation of values.

    Multiple NamespaceManagers created with a particular name will all
    share access to the same underlying datasource and will attempt to
    synchronize against a common mutex object.  The scope of this
    sharing may be within a single process or across multiple
    processes, depending on the type of NamespaceManager used.

    The NamespaceManager itself is generally threadsafe, except in the
    case of the DBMNamespaceManager in conjunction with the gdbm dbm
    implementation.

    cCsdS)z`Initialize module-level dependent libraries required
        by this :class:`.NamespaceManager`.Nr)�clsrrr�_init_dependencies:sz#NamespaceManager._init_dependenciescCs|��||_dS)N)r �	namespace)�selfr!rrr�__init__?szNamespaceManager.__init__cCs
t��dS)a+Return a locking object that is used to synchronize
        multiple threads or processes which wish to generate a new
        cache value.

        This function is typically an instance of
        :class:`.FileSynchronizer`, :class:`.ConditionSynchronizer`,
        or :class:`.null_synchronizer`.

        The creation lock is only used when a requested value
        does not exist, or has been expired, and is only used
        by the :class:`.Value` key-management object in conjunction
        with a "createfunc" value-creation function.

        N)�NotImplementedError)r"�keyrrr�get_creation_lockCsz"NamespaceManager.get_creation_lockcCs
t��dS)aImplement removal of the entire contents of this
        :class:`.NamespaceManager`.

        e.g. for a file-based namespace, this would remove
        all the files.

        The front-end to this method is the
        :meth:`.NamespaceManager.remove` method.

        N)r$)r"rrr�	do_removeTszNamespaceManager.do_removecCsdS)z�Establish a read lock.

        This operation is called before a key is read.    By
        default the function does nothing.

        Nr)r"rrr�acquire_read_lockasz"NamespaceManager.acquire_read_lockcCsdS)z�Release a read lock.

        This operation is called after a key is read.    By
        default the function does nothing.

        Nr)r"rrr�release_read_lockisz"NamespaceManager.release_read_lockTFcCsdS)a�Establish a write lock.

        This operation is called before a key is written.
        A return value of ``True`` indicates the lock has
        been acquired.

        By default the function returns ``True`` unconditionally.

        'replace' is a hint indicating the full contents
        of the namespace may be safely discarded. Some backends
        may implement this (i.e. file backend won't unpickle the
        current contents).

        Tr)r"�wait�replacerrr�acquire_write_lockqsz#NamespaceManager.acquire_write_lockcCsdS)z�Release a write lock.

        This operation is called after a new value is written.
        By default this function does nothing.

        Nr)r"rrr�release_write_lock�sz#NamespaceManager.release_write_lockcCs
|�|�S)zYReturn ``True`` if the given key is present in this
        :class:`.Namespace`.
        )�__contains__)r"r%rrr�has_key�szNamespaceManager.has_keycCs
t��dS)N)r$)r"r%rrr�__getitem__�szNamespaceManager.__getitem__cCs
t��dS)N)r$)r"r%�valuerrr�__setitem__�szNamespaceManager.__setitem__NcCs|||<dS)z�Sets a value in this :class:`.NamespaceManager`.

        This is the same as ``__setitem__()``, but
        also allows an expiration time to be passed
        at the same time.

        Nr)r"r%r1�
expiretimerrr�	set_value�szNamespaceManager.set_valuecCs
t��dS)N)r$)r"r%rrrr.�szNamespaceManager.__contains__cCs
t��dS)N)r$)r"r%rrr�__delitem__�szNamespaceManager.__delitem__cCs
t��dS)z�Return the list of all keys.

        This method may not be supported by all
        :class:`.NamespaceManager` implementations.

        N)r$)r"rrr�keys�szNamespaceManager.keyscCs|��dS)z�Remove the entire contents of this
        :class:`.NamespaceManager`.

        e.g. for a file-based namespace, this would remove
        all the files.
        N)r')r"rrr�remove�szNamespaceManager.remove)TF)N)�__name__�
__module__�__qualname__�__doc__�classmethodr r#r&r'r(r)r,r-r/r0r2r4r.r5r6r7rrrrrs"



	c@sneZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	ddd�Z
dd�Zddd�Zddd�Z
dd�ZdS)rzzA NamespaceManager where read/write operations require opening/
    closing of a resource which is possibly mutexed.

    cCs*t�||�|��|_d|_t��|_dS)Nr)rr#�get_access_lock�access_lock�openersr
�Lock�mutex)r"r!rrrr#�s
z%OpenResourceNamespaceManager.__init__cCs
t��dS)N)r$)r"rrrr=�sz,OpenResourceNamespaceManager.get_access_lockcCs
t��dS)N)r$)r"�flagsr+rrr�do_open�sz$OpenResourceNamespaceManager.do_opencCs
t��dS)N)r$)r"rrr�do_close�sz%OpenResourceNamespaceManager.do_closecCs:|j��y|jddd�Wn|j���YnXdS)N�rT)�
checkcount)r>r(�openr))r"rrrr(�s

z.OpenResourceNamespaceManager.acquire_read_lockcCs"z|jdd�Wd|j��XdS)NT)rF)�closer>r))r"rrrr)�sz.OpenResourceNamespaceManager.release_read_lockTFcCsF|j�|�}y|s|r&|jdd|d�|S|j���YnXdS)N�cT)rFr+)r>r,rGr-)r"r*r+rErrrr,�s
z/OpenResourceNamespaceManager.acquire_write_lockcCs"z|jdd�Wd|j��XdS)NT)rF)rHr>r-)r"rrrr-�sz/OpenResourceNamespaceManager.release_write_lockcCs\|j��z@|r6|jdkr&|�||�|jd7_n|�||�d|_Wd|j��XdS)Nrr)rA�acquirer?rC�release)r"rBrFr+rrrrG�s


z!OpenResourceNamespaceManager.opencCs^|j��zB|r2|jd8_|jdkrJ|��n|jdkrD|��d|_Wd|j��XdS)Nrr)rArJr?rDrK)r"rFrrrrH�s




z"OpenResourceNamespaceManager.closecCs4|j��z|jdd�|��Wd|j��XdS)NF)rF)r>r,rHr'r-)r"rrrr7s

z#OpenResourceNamespaceManager.removeN)TF)FF)F)r8r9r:r;r#r=rCrDr(r)r,r-rGrHr7rrrrr�s



c@s`eZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zddd�Zdd�Z
dS)rz�Implements synchronization, expiration, and value-creation logic
    for a single value stored in a :class:`.NamespaceManager`.

    )r%�
createfuncr3�expire_argument�	starttime�
storedtimer!NcCs(||_||_||_||_d|_||_dS)N���)r%rLrMrNrOr!)r"r%r!rLr3rNrrrr#szValue.__init__cCs(|j��z|j|jkS|j��XdS)zrreturn true if the container has a value stored.

        This is regardless of it being expired or not.

        N)r!r(r%r))r"rrr�	has_value s
zValue.has_valuecCs|��p|jdk	S)N)�has_current_valuerL)r"rrr�can_have_value,szValue.can_have_valuecCsb|j��zF|j|jk}|rNy|��\}}}|�||�Stk
rLYnXdS|j��XdS)NF)r!r(r%�
_get_value�_is_expired�KeyErrorr))r"rQ�stored�expiredr1rrrrR/s
zValue.has_current_valuecCs,|jdk	r||jkp*|dk	o*t��||kS)z1Return true if this container's value is expired.N)rN�time)r"rOr3rrrrU=s

zValue._is_expiredcCsb|j��z\|��}|rTy"|��\}}}|�||�s8|SWntk
rRd}YnX|jsdt|j��Wd|j��Xd}|j�	|j�}|r�|j
dd�s�td�|Std�d}|s�td�|�
�td�z�|j��zJ|���ry$|��\}}}|�||��s|SWntk
�rYnXWd|j��Xtd�|��}|�|�|S|�
�td	�XdS)
NF)r*z6get_value returning old value while new one is createdzlock_creatfunc (didnt wait)Tzlock_createfunc (waiting)zlock_createfunc (waited)zget_value creating new valuezreleased create lock)r!r(rQrTrUrVrLr%r)r&rJrr4rK)r"rQrWrXr1Zhas_createlockZ
creation_lock�vrrr�	get_valueKsT





zValue.get_valuecCs�|j|j}y|\}}}Wnztk
rxt|�dks8�|\}}|j}td||j�|j��|�||�|j��Ynt	k
r�t
|j��YnX|||fS)N�z*get_value upgrading time %r expire time %r)r!r%�
ValueError�lenrMrr)r4r(�	TypeErrorrV)r"r1rWrXrrrrT�s
zValue._get_valuecCs\|j��z@|dkrt��}td||j�|jj|j||j|f|jd�Wd|j��XdS)Nz'set_value stored time %r expire time %r)r3)r!r,rYrrMr4r%r-)r"r1rOrrrr4�s
zValue.set_valuecCs^|j��zBtd�|j|jkrDy|j|j=Wntk
rBYnXd|_Wd|j��XdS)N�clear_valuerP)r!r,rr%rVrOr-)r"rrrr`�s

zValue.clear_value)NNN)N)r8r9r:r;�	__slots__r#rQrSrRrUr[rTr4r`rrrrrs
8
c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�AbstractDictionaryNSManagera�A subclassable NamespaceManager that places data in a dictionary.

    Subclasses should provide a "dictionary" attribute or descriptor
    which returns a dict-like object.   The dictionary will store keys
    that are local to the "namespace" attribute of this manager, so
    ensure that the dictionary will not be used by any other namespace.

    e.g.::

        import collections
        cached_data = collections.defaultdict(dict)

        class MyDictionaryManager(AbstractDictionaryNSManager):
            def __init__(self, namespace):
                AbstractDictionaryNSManager.__init__(self, namespace)
                self.dictionary = cached_data[self.namespace]

    The above stores data in a global dictionary called "cached_data",
    which is structured as a dictionary of dictionaries, keyed
    first on namespace name to a sub-dictionary, then on actual
    cache key to value.

    cCstd|j|fdd�S)Nzmemorynamespace/funclock/%s/%sT)�
identifierZ	reentrant)r
r!)r"r%rrrr&�s
z-AbstractDictionaryNSManager.get_creation_lockcCs
|j|S)N)�
dictionary)r"r%rrrr0�sz'AbstractDictionaryNSManager.__getitem__cCs|j�|�S)N)rdr.)r"r%rrrr.�sz(AbstractDictionaryNSManager.__contains__cCs|j�|�S)N)rdr.)r"r%rrrr/�sz#AbstractDictionaryNSManager.has_keycCs||j|<dS)N)rd)r"r%r1rrrr2�sz'AbstractDictionaryNSManager.__setitem__cCs|j|=dS)N)rd)r"r%rrrr5�sz'AbstractDictionaryNSManager.__delitem__cCs|j��dS)N)rd�clear)r"rrrr'�sz%AbstractDictionaryNSManager.do_removecCs
|j��S)N)rdr6)r"rrrr6�sz AbstractDictionaryNSManager.keysN)r8r9r:r;r&r0r.r/r2r5r'r6rrrrrb�srbc@s eZdZdZe��Zdd�ZdS)rzE:class:`.NamespaceManager` that uses a Python dictionary for storage.cKs"t�||�tj�|jt�|_dS)N)rbr#r�
namespaces�getr!�dictrd)r"r!�kwargsrrrr#�szMemoryNamespaceManager.__init__N)r8r9r:r;�utilZSyncDictrfr#rrrrr�sc@s�eZdZdZd"dd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�ZdS)#rz?:class:`.NamespaceManager` that uses ``dbm`` files for storage.NTcKs�||_|s|std��n|r$||_n
|d|_t�|j�|sL|sLtd��n|rX||_n
|d|_t�|j�|ptt|_d|_t	�
||�tj|j|jgd|jd�|_
td|j
�|��dS)Nzdata_dir or dbm_dir is requiredz/container_dbmz data_dir or lock_dir is requiredz/container_dbm_lockz.dbm)�root�identifiers�	extension�digest_filenameszdata file %s)rnr	�dbm_dirrj�verify_directory�lock_dirr�	dbmmodule�dbmrr#�encoded_pathr!�filer�
_checkfile)r"r!rr�data_dirrorqrnrirrrr#�s,




zDBMNamespaceManager.__init__cCst|j|jd�S)N)rcrq)rr!rq)r"rrrr=sz#DBMNamespaceManager.get_access_lockcCstd|j|f|jd�S)Nzdbmcontainer/funclock/%s/%s)rcrq)rr!rq)r"r%rrrr&s
z%DBMNamespaceManager.get_creation_lockcCs@t�|tj�rdSx(dD] }t�|tj|tj�rdSqWdS)NT)�db�dat�pag�dirF)�os�access�F_OK�extsep)r"ru�extrrr�file_exists$s
zDBMNamespaceManager.file_existscCs&tj�|�}tj�|�s"t�|�dS)N)r|�path�dirname�existsrjrp)r"�filenamer�rrr�
_ensuredir.szDBMNamespaceManager._ensuredircCs4|�|j�s0|�|j�|j�|jd�}|��dS)NrI)r�rur�rrrGrH)r"�grrrrv3szDBMNamespaceManager._checkfilecCsbg}t�|jtj�r |�|j�x<dD]4}t�|jtj|tj�r&|�|jtj|�q&W|S)N)rzr{rxry)r|r}rur~�appendr)r"�listr�rrr�
get_filenames9s
z!DBMNamespaceManager.get_filenamescCsNtd|j�y|j�|j|�|_Wn&|��|j�|j|�|_YnXdS)Nzopening dbm file %s)rrurrrGrsrv)r"rBr+rrrrCCszDBMNamespaceManager.do_opencCs$|jdk	r td|j�|j��dS)Nzclosing dbm file %s)rsrrurH)r"rrrrDKs
zDBMNamespaceManager.do_closecCs x|��D]}t�|�q
WdS)N)r�r|r7)r"�frrrr'PszDBMNamespaceManager.do_removecCst�|j|�S)N)r�loadsrs)r"r%rrrr0TszDBMNamespaceManager.__getitem__cCs&tdkrt|t�r|�d�}||jkS)N)�r\zUTF-8)r�
isinstancer�encoders)r"r%rrrr.Ws

z DBMNamespaceManager.__contains__cCst�|�|j|<dS)N)r�dumpsrs)r"r%r1rrrr2_szDBMNamespaceManager.__setitem__cCs|j|=dS)N)rs)r"r%rrrr5bszDBMNamespaceManager.__delitem__cCs
|j��S)N)rsr6)r"rrrr6eszDBMNamespaceManager.keys)NNNNT)r8r9r:r;r#r=r&r�r�rvr�rCrDr'r0r.r2r5r6rrrrr�s$
 

c@sreZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)rz�:class:`.NamespaceManager` that uses binary files for storage.

    Each namespace is implemented as a single file storing a
    dictionary of key/value pairs, serialized using the Python
    ``pickle`` module.

    NTcKs�||_|s|std��n|r$||_n
|d|_t�|j�|sL|sLtd��n|rX||_n
|d|_t�|j�t�||�tj|j|j	gd|jd�|_
i|_td|j
�dS)Nz data_dir or file_dir is requiredz/container_filez data_dir or lock_dir is requiredz/container_file_lockz.cache)rkrlrmrnzdata file %s)
rnr	�file_dirrjrprqrr#rtr!ru�hashr)r"r!rwr�rqrnrirrrr#qs(



zFileNamespaceManager.__init__cCst|j|jd�S)N)rcrq)rr!rq)r"rrrr=�sz$FileNamespaceManager.get_access_lockcCstd|j|f|jd�S)Nzdbmcontainer/funclock/%s/%s)rcrq)rr!rq)r"r%rrrr&�s
z&FileNamespaceManager.get_creation_lockcCst�|tj�S)N)r|r}r~)r"rurrrr��sz FileNamespaceManager.file_existsc
Csz|sp|�|j�rpy(t|jd��}t�|�|_WdQRXWn6tk
rn}z|jtjtj	gkr^�Wdd}~XYnX||_
dS)N�rb)r�rurGr�loadr��IOError�errno�EACCES�ENOENTrB)r"rBr+Zfh�errrrC�szFileNamespaceManager.do_opencCs>|jdks|jdkr.t�|j�}t�|j|�i|_d|_dS)NrI�w)rBrr�r�rjZ
safe_writeru)r"ZpickledrrrrD�s
zFileNamespaceManager.do_closecCs0yt�|j�Wntk
r$YnXi|_dS)N)r|r7ru�OSErrorr�)r"rrrr'�s
zFileNamespaceManager.do_removecCs
|j|S)N)r�)r"r%rrrr0�sz FileNamespaceManager.__getitem__cCs
||jkS)N)r�)r"r%rrrr.�sz!FileNamespaceManager.__contains__cCs||j|<dS)N)r�)r"r%r1rrrr2�sz FileNamespaceManager.__setitem__cCs|j|=dS)N)r�)r"r%rrrr5�sz FileNamespaceManager.__delitem__cCs
|j��S)N)r�r6)r"rrrr6�szFileNamespaceManager.keys)NNNT)r8r9r:r;r#r=r&r�rCrDr'r0r.r2r5r6rrrrris

	c@seZdZdd�Zddd�ZdS)�
ContainerMetacCs|jt|<t�||||�S)N)�namespace_class�namespace_classes�typer#)r�	classname�basesZdict_rrrr#�s
zContainerMeta.__init__Nc
Ks@||kr||}nt|}	|	|f|�||<}t|||||d�S)N)rLr3rN)r�r)
r"r%�contextr!rLr3rNri�nsZnsclsrrr�__call__�s
zContainerMeta.__call__)NNN)r8r9r:r#r�rrrrr��sr�c@seZdZdZeZdS)rz�Implements synchronization and value-creation logic
    for a 'value' stored in a :class:`.NamespaceManager`.

    :class:`.Container` and its subclasses are deprecated.   The
    :class:`.Value` class is now used for this purpose.

    N)r8r9r:r;rr�rrrrr�sc@seZdZeZdS)rN)r8r9r:rr�rrrrr�sc@seZdZeZdS)rN)r8r9r:rr�rrrrr�sc@seZdZeZdS)rN)r8r9r:rr�rrrrr�s).r;r��_compatrrrrrZbeaker.utilrjZloggingr|rYZbeaker.exceptionsrr	Zbeaker.synchronizationr
rrr
r�__all__Z	getLogger�loggerZisEnabledFor�DEBUGr�objectrrrrbrrrr�rhrr�r�rrrrZDbmContainerrrrr�<module>sF
V$6vd

Youez - 2016 - github.com/yon3zu
LinuXploit