%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/aptdaemon/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/aptdaemon/__pycache__/lock.cpython-312.pyc

�

��kd����dZdZdZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZGd�d	e
�ZGd
�de�Zd�Zej$�ej&j)ej*j-d
��Zeej&j1ed��Zeej&j1ed��Zej*j7d�Zeej&j1ed��Zeej&j1ej*j7d�d��Zd�Zd�Z dd�Z!y)zHandles the apt system lockz%Sebastian Heinlein <devel@glatzor.de>)�LockFailedError�system�N)�GLib)�enums)�TransactionCancelledc��eZdZdZdd�Zy)rzThe locking of file failed.Nc�j�d|z}|r|d|zz
}tj||�||_||_y)z�Return a new LockFailedError instance.

        Keyword arguments:
        flock -- the path of the file lock
        process -- the process which holds the lock or None
        zCould not acquire lock on %s.z The lock is held by %s.N)�	Exception�__init__�flock�process)�selfrr
�msgs    �0/usr/lib/python3/dist-packages/aptdaemon/lock.pyrzLockFailedError.__init__'s?��.��5����-��7�7�C����4��%���
�����N)�__name__�
__module__�__qualname__�__doc__r�rrrr#s
��%�rrc�2�eZdZdZd�Zed��Zd�Zd�Zy)�FileLockzRepresents a file lock.c� �||_d|_yr)�path�fd)rrs  rrzFileLock.__init__:s����	���rc��|jduSr)r�rs r�lockedzFileLock.locked>s���w�w�d�"�"rc���|jr|jStj|j�}|dkr+t	|j�}t|j|��||_|S)zuReturn the file descriptor of the lock file or raise
        LockFailedError if the lock cannot be obtained.
        r)r�apt_pkg�get_lockr�get_locking_process_namer)r�fd_lockr
s   r�acquirezFileLock.acquireBsZ���7�7��7�7�N��"�"�4�9�9�-���Q�;�.�t�y�y�9�G�!�$�)�)�W�5�5��D�G��Nrc�j�|jr'tj|j�d|_yy)zRelase the lock.N)r�os�closers r�releasezFileLock.releasePs%���7�7��H�H�T�W�W���D�G�rN)	rrrrr�propertyrr%r)rrrrr6s(��!���#��#��rrc���	t|d�}tjdtjt
jddd�}tj|tj|�}tjd|�d}	td|zd�5}	d�|j�D�D]5\}}|dk(s�|j�ccddd�|j�S	ddd�|j�y#t$rYddd�|j�ywxYw#1swY�AxYw#t$rY|j�ywxYw#|j�wxYw#t$rYywxYw)	zjReturn the name of a process which holds a lock. It will be None if
    the name cannot be retrivied.
    �r�hhQQir�z/proc/%s/statusc3�>K�|]}|jd����y�w)�:N)�split)�.0�lines  r�	<genexpr>z+get_locking_process_name.<locals>.<genexpr>hs����'>�4�t�z�z�#��'>�s��NameN)�open�struct�pack�fcntl�F_WRLCKr'�SEEK_SET�F_GETLK�unpack�	readlines�stripr(r
�IOError)�	lock_path�fd_lock_read�flk�flk_ret�pid�	fd_status�key�values        rr#r#Ws[��!��I�s�+��
�k�k�'�5�=�=�"�+�+�q�!�Q�G���+�+�l�E�M�M�3�?���m�m�G�W�-�a�0��	!��'�#�-�s�3�
 �y� �'>�'0�':�':�'<�'>�1�
��U��&�=�#(�;�;�=�0�
 �
 �
��� �1�
 �
��� ���
!� ��
 �
��� � ��

 �
 ���	����� �	��
��� ��)����s��E$�D0�D$�"C=�7C=�	D0�"C=�$D0�=	D!�D$�D0� D!�!D$�$D-�)D0�0	E�9E�E�E�E!�$	E0�/E0zDir::State::status�lockz
lock-frontendzDir::Cache::ArchiveszDir::State::listsc��	ttttfD]}|jr�|j��!	dtjd<y#t
��xYw)z<Acquire an exclusive lock for the package management system.�1�DPKG_FRONTEND_LOCKEDN)	�
frontend_lock�status_lock�archive_lock�
lists_lockrr%r)r'�environ�rIs rr%r%�sO���!�;��j�H�	�D��;�;�����	�*-�B�J�J�%�&��	��	�
�s�%A�A�
Ac��ttttfD]}|j	��	t
jd=y#t$rYywxYw)z<Release an exclusive lock for the package management system.rLN)rPrOrNrMr)r'rQ�KeyErrorrRs rr)r)�sG���L�+�}�D��������
��J�J�-�.���
��
�s�?�	A�
Ac�>�����fd�}	�r�j�yt�y#t$r�}d�_tj�_|jr%�jd�}||jz�_tjd|�}�jrG�js;tj�j��jr
�js�;tj|��jr
t��Yd}~yd}~wwxYw)z�Acquire the system lock or the optionally given one. If the lock
    cannot be obtained pause the transaction in the meantime.

    :param trans: the transaction
    :param lock: optional alternative lock
    c�n��	�r�j�n
t�d�_y#t$rYywxYw)z�Helper to unpause the transaction if the lock can be obtained.

        Keyword arguments:
        trans -- the corresponding transaction
        alt_lock -- alternative lock to the system lock
        TF)r%r�paused)�alt_lock�transs��r�
watch_lockz!wait_for_lock.<locals>.watch_lock�s<���	��� � �"��	�������	��	�s�(�	4�4TzWaiting for %s to exit�N)r%rrWr�STATUS_WAITING_LOCK�statusr
�gettext�status_detailsr�timeout_add_seconds�	cancelled�main_context_default�	iteration�
source_remover)rYrXrZ�errorr�
lock_watchs``    r�
wait_for_lockrg�s�����")�������I���)�����0�0����=�=��-�-� 8�9�C�#&����#6�E� ��-�-�a��<�
��l�l�5�?�?��%�%�'�1�1�3��l�l�5�?�?����:�&��?�?�&�(�(���)�s�(�
(�	D�B5D�'+D�Dr)"r�
__author__�__all__r9r'r7r!�
gi.repositoryr�	aptdaemonr�aptdaemon.errorsrr
r�objectrr#�initr�dirname�config�	find_file�_status_dir�joinrNrM�find_dir�
_archives_dirrOrPr%r)rgrrr�<module>rvs��"�"5�
�
'���	�
����1��i��&�v��B�:
������g�g�o�o�g�n�n�6�6�7K�L�M���r�w�w�|�|�K��8�9��������k�?�C�D�
����'�'�(>�?�
�������]�F�;�<���b�g�g�l�l��N�N���/�0�&�:�;�
�
-�
�))r

Zerion Mini Shell 1.0