
                         b    S SK r S SKrS SKrS SKrS SKrS SKJr   " S S\R                  5      rg)    N)locked_filec                   ,    \ rS rSrSrSrSrS rS rSr	g)	_Win32Opener   z7Open, lock, and unlock a file using windows primitives.!      c                    U R                   (       a/  [        R                  " SR                  U R                  5      5      e[
        R
                  " 5       n[        R                  " U R                  5         [        U R                  U R                  5      U l	          [        R                  " U R                  R!                  5       5      n[        R"                  " U[$        R&                  [$        R(                  -  SS[*        R,                  " 5       5        SU l         g! [         aR  nUR                  [        R                  :X  a*  [        U R                  U R                  5      U l	         SnAg SnANSnAff = f! [*        R.                   a  nUS:X  a  e US   [0        R2                  :w  a  e [
        R
                  " 5       U-
  U:  a  [        R4                  R7                  SU R                  U5        U R                  (       a  U R                  R9                  5         [        U R                  U R                  5      U l	         SnAg[
        R:                  " U5         SnAOSnAff = fGM  )aX  Open the file and lock it.

Args:
    timeout: float, How long to try to lock for.
    delay: float, How long to wait between retries

Raises:
    AlreadyLockedException: if the lock is already acquired.
    IOError: if the open fails.
    CredentialsFileSymbolicLinkError: if the file is a symbolic
                                      link.
zFile {0} is already lockedNTr     zCould not lock %s in %s seconds)_lockedr   AlreadyLockedExceptionformat	_filenametimevalidate_fileopen_mode_fhIOErrorerrnoEACCES_fallback_mode	win32file_get_osfhandlefileno
LockFileExwin32conLOCKFILE_FAIL_IMMEDIATELYLOCKFILE_EXCLUSIVE_LOCK
pywintypes
OVERLAPPEDerrorr   FILE_IN_USE_ERRORloggerwarnclosesleep)selftimeoutdelay
start_timeehfiles         5lib/third_party/oauth2client/contrib/_win32_opener.pyopen_and_lock_Win32Opener.open_and_lock$   s    <<44,33DNNCE EYY[
!!$..1	DNNDJJ7DH "!001BC$$77556898))+	-
  $#  	 ww%,,&0C0CD '	$ ## "a< Q4<999 IIK*,8&&++,M,0NNGExx(#DNND4G4GHDH

5!!#" s9   7%D  BE?  
E<*AE77E<?I.B6I)I))I.c                    U R                   (       a[   [        R                  " U R                  R	                  5       5      n[        R
                  " USS[        R                  " 5       5        SU l         U R                  (       a  U R                  R                  5         gg! [        R                   a"  nUS   [        R                  :w  a  e  SnANeSnAff = f)z4Close and unlock the file using the win32 primitive.r   r
   NF)r   r   r   r   r   UnlockFileExr   r    r!   r   FILE_ALREADY_UNLOCKED_ERRORr%   )r'   r,   r+   s      r-   unlock_and_close_Win32Opener.unlock_and_close^   s    <<!001BC&&ua'1'<'<'>@
 88HHNN 	 ## Q4<CCC Ds   AB! !C5CC)r   r   N)
__name__
__module____qualname____firstlineno____doc__r"   r2   r.   r3   __static_attributes__     r-   r   r      s     A  #&8"tr<   r   )	r   r   r   r   r   oauth2client.contribr   _Openerr   r;   r<   r-   <module>r?      s-         ,Q;&& Qr<   