Your IP : 3.15.144.162


Current Path : /lib/python2.7/site-packages/pip/_vendor/lockfile/
Upload File :
Current File : //lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pyc

�
��abc@`s�ddlmZmZddlZddlZyeWnek
rOeZnXddlm	Z	m
Z
mZmZm
Z
de	fd��YZdS(i(tabsolute_importtdivisionNi(tLockBaset	NotLockedt	NotMyLocktLockTimeoutt
AlreadyLockedtSQLiteLockFilecB`s\eZdZdZedd�Zdd�Zd�Zd�Z	d�Z
d�Zd�ZRS(	sDemonstrate SQL-based locking.c
C`stj||||�t|j�|_t|j�|_tjdkr�ddl}|j	�\}}t
j|�t
j|�~~|t_nddl
}|jtj�|_|jj�}y|jd�Wn|jk
r�n0X|jj�ddl}	|	jt
jtj�dS(su
        >>> lock = SQLiteLockFile('somefile')
        >>> lock = SQLiteLockFile('somefile', threaded=False)
        iNsGcreate table locks(   lock_file varchar(32),   unique_name varchar(32))(Rt__init__tunicodet	lock_filetunique_nameRttestdbtNonettempfiletmkstemptostclosetunlinktsqlite3tconnectt
connectiontcursortexecutetOperationalErrortcommittatexittregister(
tselftpathtthreadedttimeoutRt_fdRRtcR((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pyRs(


cC`s�|dk	r|n|j}tj�}|dk	rL|dkrL||7}n|dkrad}n|dkrvd}n
|d}|jj�}x;tr�|j�s.|jd|j|j	f�|jj
�|jd|j	f�|j�}t|�dkr'|jd|j	f�|jj
�qfdSn8|jd|j	f�|j�}t|�dkrfdS|dk	r�tj�|kr�|dkr�t
d|j��q�td	|j��ntj|�q�WdS(
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 = ?s&Timeout waiting to acquire lock for %ss%s is already locked(R
RttimeRRtTruet	is_lockedRR
RRtfetchalltlenRRRtsleep(RRtend_timetwaitRtrows((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pytacquire5sD
		
		
	
	
	
cC`s�|j�s"td|j��n|j�sPtd|j|j�f��n|jj�}|j	d|jf�|jj
�dS(Ns%s is not lockeds#%s is locked, but not by me (by %s)s(delete from locks  where unique_name = ?(R$RRti_am_lockingRRt_who_is_lockingRRRR(RR((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pytreleasets	
cC`s3|jj�}|jd|jf�|j�dS(Ns2select unique_name from locks  where lock_file = ?i(RRRR
tfetchone(RR((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pyR-�s	
cC`s7|jj�}|jd|jf�|j�}|S(Ns(select * from locks  where lock_file = ?(RRRR
R%(RRR*((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pyR$�s
	
cC`s7|jj�}|jd|j|jf�|j�S(Ns?select * from locks  where lock_file = ?    and unique_name = ?(RRRR
RR%(RR((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pyR,�s	cC`s6|jj�}|jd|jf�|jj�dS(Ns&delete from locks  where lock_file = ?(RRRR
R(RR((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pyt
break_lock�s	
N(
t__name__t
__module__t__doc__R
RR#RR+R.R-R$R,R0(((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pyRs"?				(t
__future__RRR"RR	t	NameErrortstrtRRRRRR(((sG/usr/lib/python2.7/site-packages/pip/_vendor/lockfile/sqlitelockfile.pyt<module>s

(

?>