+
    =l j­  ã                   ó>  € ^ RI t ^ RIt^ RIt^ RIHt ^ RIHtHtHt ^ RI	H
t
HtHt ^ RIHt ^ RIHtHt ^ RIHt ^ RIHt ] P,                  ! ]P.                  ! ]4      4      t ! R	 R
]
4      t]! ]]! RRR7      ]P6                  4      tR R ltR t ! R R4      tR# )é    N)ÚTuple)Ú
exceptionsÚsystemÚutil)Ú
DataObjectÚFieldÚStringDataValue)Únotices)ÚDataObjectFileÚDataObjectFileFormat)ÚUAFile)ÚNoticec                   óV   a € ] tR t^t o ]! R]4      ]! R]4      .tV 3R lR ltRtV t	R# )ÚLockDataÚlock_pidÚlock_holderc                ó&   <€ V ^8„  d   QhRS[ RS[ /# )é   r   r   )Ústr)ÚformatÚ__classdict__s   "€Ú//usr/lib/python3/dist-packages/uaclient/lock.pyÚ__annotate__ÚLockData.__annotate__   s   ø€ ÷ 'ñ '¡ð '±3ñ 'ó    c                ó   € Wn         W n        R # ©N©r   r   )Úselfr   r   s   &&&r   Ú__init__ÚLockData.__init__   s   € Ø ŒØ&Ör   )r   r   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r	   Úfieldsr    Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      s*   ø‡ € áˆj˜/Ó*Ùˆm˜_Ó-ð€F÷
'ö 'r   r   ÚlockF)Úprivatec                óF   € V ^8„  d   QhR\         \        \        3,          /# )r   Úreturn)r   Úintr   )r   s   "r   r   r   "   s   € ÷ 'ñ 'œœs¤C˜x�ñ 'r   c                 ón  €  \         P                  4       p RpT '       g   T# T P                  pT P                  p \        P                  ! RT.4       \        T4      T3#   \        P                   d'    \        P                  ! \         P
                  R7      hi ; i  \        P                   d‚    \        P                  ! 4       '       g'   \        P                  RTT4       \        T4      T3u # \        P!                  RTT4       \        P"                  ! \         P
                  4       Tu # i ; i)z÷Return lock info if lock file is present the lock is active.

If process claiming the lock is no longer present, remove the lock file
and log a warning.

:return: A tuple (pid, string describing lock holder)
    If no active lock, pid will be -1.
)Úlock_file_pathÚpsz.Found stale lock file previously held by %s:%sz1Removing stale lock file previously held by %s:%s)éÿÿÿÿÚ )Úlock_data_fileÚreadr   ÚInvalidFileFormatErrorÚInvalidLockFileÚpathr   r   r   Úsubpr.   ÚProcessExecutionErrorr   Úwe_are_currently_rootÚLOGÚdebugÚwarningÚensure_file_absent)Úlock_data_objÚno_lockr   r   s       r   Úcheck_lock_inforB   "   s  € ðMÜ&×+Ñ+Ó-ˆð €GßØˆà×%Ñ%€HØ×+Ñ+€KðÜ�Š�T˜8Ð$Ô%Ü�H“˜{Ð+Ð+øô ×,Ñ,ô MÜ×(Ò(¼×8KÑ8KÔLÐLðMûô ×+Ñ+ô Ü×)Ò)×+Ò+Ü�I‰IØ@ØØôô
 ˜“M ;Ð/Ò/Ü�‰Ø?ØØô	
ô
 	×!Ò!¤.×"5Ñ"5Ô6ØŠðús(   ‚A  »$B Á ;BÂ/D4Ã$D4Ã4=D4Ä3D4c                  ó.   € \         P                  4        R # r   )r4   Údelete© r   r   Úclear_lock_file_if_presentrF   L   s   € Ü×ÑÖr   c                   óT   a € ] tR t^Pt o RtR^
R^/V 3R lR lltR tR tR tR	t	V t
R
# )Ú	RetryLocka,  
Context manager for gaining exclusive access to the lock file.

Create a lock file if absent. The lock file will contain a pid of the
running process, and a customer-visible description of the lock holder.

The RetryLock will try several times to acquire the lock before giving up.
The number of times to try and how long to sleep in between tries is
configurable.

:param lock_holder: String with the service name or command which is
    holding the lock. This lock_holder string will be customer visible in
    status.json.
:param sleep_time: Number of seconds to sleep before retrying if the lock
    is already held.
:param max_retries: Maximum number of times to try to grab the lock before
    giving up and raising a LockHeldError.
:raises: LockHeldError if lock is held after (sleep_time * max_retries)
Ú
sleep_timeÚmax_retriesc                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r   r   rI   rJ   )r   r.   )r   r   s   "€r   r   ÚRetryLock.__annotate__e   s+   ø€ ÷ 	'ñ 	'ñ ð	'ñ ð		'ñ
 ñ	'r   c               ó*   € Wn         W n        W0n        R # r   )r   rI   rJ   )r   r   rI   rJ   Ú_argss   &$$$*r   r    ÚRetryLock.__init__e   s   € ð 'ÔØ$ŒØ&Ör   c                ó^  € \        4       w  rV^ 8”  d$   \        P                  ! V P                  VVR7      h\        P                  \        \        \        P                  ! 4       4      V P                  R7      4       \        P                  ! \        P                  V P                  R7       R# )r   )Úlock_requestr   Úpidr   )Ú	operationN)rB   r   ÚLockHeldErrorr   r4   Úwriter   r   ÚosÚgetpidr
   Úaddr   ÚOPERATION_IN_PROGRESS)r   r   Úcur_lock_holders   &  r   Ú	grab_lockÚRetryLock.grab_lockp   s�   € Ü&5Ó&7Ñ#ˆØ�aŒ<Ü×*Ò*Ø!×-Ñ-Ø+Øôð ô
 	×ÑÜœc¤"§)¢)£+Ó.¸D×<LÑ<LÔMô	
ô 	�ŠÜ×(Ñ(Ø×&Ñ&÷	
r   c                óz  € \         P                  R V P                  4       ^ p  V P                  4        R#   \        P
                   do   p\         P                  RT^,           TP                  4       T^,          pYP                  8¼  d   Th\        P                  ! T P                  4        Rp?K’  Rp?ii ; i)zspin lock starting for %sz%RetryLock Attempt %d. %s. Spinning...N)r<   r=   r   r[   r   rT   ÚmsgrJ   ÚtimeÚsleeprI   )r   ÚtriesÚes   &  r   Ú	__enter__ÚRetryLock.__enter__€   s‘   € Ü�	‰	Ð-¨t×/?Ñ/?Ô@ØˆØð0Ø—‘Ô ÙøÜ×+Ñ+ô 0Ü—	‘	Ø;¸UÀQ½YÈÏÉôð ˜•
�Ø×,Ñ,Ô,Ø�Gä—J’J˜tŸ™×/Ò/ûð0ús   ¥7 ·B:ÁA#B5Â5B:c                óv   € \         P                  4        \        P                  ! \        P
                  4       R # r   )r4   rD   r
   Úremover   rY   )r   Ú	_exc_typeÚ
_exc_valueÚ
_tracebacks   &&&&r   Ú__exit__ÚRetryLock.__exit__‘   s    € Ü×ÑÔÜ�Š”v×3Ñ3Ö4r   )r   rJ   rI   N)r"   r#   r$   r%   Ú__doc__r    r[   rc   rj   r'   r(   r)   s   @r   rH   rH   P   s<   ø‡ € ñð(	'ð ð		'ð
 ÷	'ò 	'ò
ò 0÷"5ð 5r   rH   ) ÚloggingrV   r_   Útypingr   Úuaclientr   r   r   Úuaclient.data_typesr   r   r	   Úuaclient.filesr
   Úuaclient.files.data_typesr   r   Úuaclient.files.filesr   Úuaclient.files.noticesr   Ú	getLoggerÚreplace_top_level_logger_namer"   r<   r   ÚJSONr4   rB   rF   rH   rE   r   r   Ú<module>rx      s‰   ðÛ Û 	Û Ý ç -Ñ -ß BÑ BÝ "ß JÝ 'Ý )à×Ò˜×:Ò:¸8ÓDÓE€ô'ˆzô 'ñ  ØÙ
ˆ6˜5Ô!Ø×Ñó€õ'òT÷C5ó C5r   