%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__/debconf.cpython-312.pyc

�

��S����dZdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZejd�Z
Gd�de�Zd�Zed	k(re�yy)
z�
Integration of debconf on the client side

Provides the DebconfProxy class which allows to run the debconf frontend
as normal user by connecting to the root running debconf through the
socket of the passthrough frontend.
)�DebconfProxy�N)�GLibzAptClient.DebconfProxyc�<�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
y)rz�The DebconfProxy class allows to run the debconf frontend
    as normal user by connecting to the root debconf through the socket of the
    passthrough frontend.
    Nc���||_d|_|�Jtjd��|_tj
j
|jd�|_tjd|jz�tjtjtj�|_	|jj|j�||_
d|_d|_g|_y)aInitialize a new DebconfProxy instance.

        Keyword arguments:
        frontend -- the to be used debconf frontend (defaults to gnome)
        socket_path -- the path to the socket of the passthrough frontend.
            Will be created if not specified
        Nz
aptdaemon-)�prefixzdebconf.socketzdebconf socket: %s)�socket_path�temp_dir�tempfile�mkdtemp�os�path�join�log�debug�socket�AF_UNIX�SOCK_STREAM�bind�frontend�_listener_id�_active_conn�
_watch_ids)�selfrrs   �3/usr/lib/python3/dist-packages/aptdaemon/debconf.py�__init__zDebconfProxy.__init__2s���'�����
���$�,�,�L�A�D�M�!�w�w�|�|�D�M�M�;K�L�D���	�	�&��)9�)9�9�:��m�m�F�N�N�F�4F�4F�G���������)�)�*� ��
� ��� ������c���tjtj�}d|d<d|d<|j|d<tj
tjk(rd|d<|S)zcReturns a dictonary of the environment variables required by
        the debconf frontend.
        �configdb�DEBCONF_DB_REPLACEzPipe{infd:none outfd:none}�DEBCONF_DB_OVERRIDE�DEBIAN_FRONTEND�.�
DEBCONF_DEBUG)�copyr�environrr�level�logging�DEBUG)r�envs  r�_get_debconf_envzDebconfProxy._get_debconf_envGsZ���i�i��
�
�#��$.�� �!�%A��!�"�!%�������9�9��
�
�%�#&�C�� ��
rc��tjd�|jjd�t	j
|jtjtj|j�|_	y)zStart listening on the socket.zdebconf.start()�N)
r'rr�listenr�io_add_watch�PRIORITY_DEFAULT_IDLE�IO_IN�_accept_connectionr�rs r�startzDebconfProxy.startSsR���
�
�'�(������1�� �-�-��K�K��3�3��J�J��/�/�1��rc�|�tjd�|jj�|j�&tj|j�d|_|jr@	tj|j�tj|j�yy#t$rYywxYw)zStop listening on the socket.zdebconf.stop()N)
r'rr�closerr�
source_remover	r�remover�rmdir�OSErrorr2s r�stopzDebconfProxy.stop[s����
�
�&�'����������(����t�0�0�1� $�D���=�=�
��	�	�$�*�*�+�������'����
��
�s�/>B/�/	B;�:B;c��|jrtjd�y|j�\}}||_tj
tjztjztjz}tjdgtjtj|j���|_
t	j|tj||j |jj"�t	j|jj$tj||j&|�y)NzDelaying connectionTzdebconf-communicate)�stdin�stdoutr))rrr�acceptrr0�IO_ERR�IO_HUP�IO_NVAL�
subprocess�Popen�PIPEr*�helperr.�PRIORITY_HIGH_IDLE�
_copy_connr<r=�_copy_stdout)rr�	condition�conn�addr�masks      rr1zDebconfProxy._accept_connectionis�������I�I�+�,��"�V�]�]�_�
��d� ����z�z�D�K�K�'�$�+�+�5����D�� �&�&�(=�'>�-7�_�_�.8�o�o�+/�+@�+@�+B�D���	
���$�� 7� 7��������1B�1B�	D����$�+�+�,�,�d�.E�.E��� 1� 1�4�	9�rc���tjd�	|j�}|r(tjd|�|j	|�y	tjd�|jjj�|jj�d|_y#t
jtf$r}tj|�Yd}~��d}~wwxYw)zaCallback to copy data from the stdout of debconf-communicate to
        the passthrough frontend.rHzFrom debconf: %sTNzStop reading from stdoutF)r'r�readliner�sendr�error�IOErrorrEr=r5r)r�sourcerIrJ�debconf_datarPs      rrHzDebconfProxy._copy_stdoutzs���	�
�
�n�%�	�!�?�?�,�L���	�	�,�l�;��	�	�,�'���	�	�	�,�-������ � �"������!� ��������g�&�	��I�I�e����	�s�9B-�-C%�C � C%c��tjd�	|jd�}|r8tjd|�|j	|�|j�y	tjd�|jjj�y#tjtf$r}tj|�Yd}~�md}~wwxYw)z\Callback to copy data from the passthrough frontend to stdin of
        debconf-communicate.rGizFrom socket: %sTNzStop reading from connF)r'r�recvr�write�flushrrPrQrEr<r5)rrRrIr<�socket_datarPs      rrGzDebconfProxy._copy_conn�s���	�
�
�l�#�	� �+�+�d�+�K���	�	�+�[�9����K�(����
��	�	�	�	�*�+��������!������g�&�	��I�I�e����	�s�A
B�C�6C�C)�gnomeN)�__name__�
__module__�__qualname__�__doc__rr*r3r:r1rHrG�rrrr+s*���
�*
�1���"�&rrc�8�tjtj��d}tjj|�rtj|�td|�}|j�tj�}|j�y)a4Run the DebconfProxy from the command line for testing purposes.

    You have to execute the following commands before in a separate terminal:
    $ echo "fset debconf/frontend seen false" | debconf-communicate
    $ export DEBCONF_PIPE=/tmp/debconf.socket
    $ dpkg-reconfigure debconf -f passthrough
    )r&z/tmp/debconf.socketrYN)r'�basicConfigr(rr
�existsr7rr3r�MainLoop�run)r�proxy�loops   r�_testrf�s`�����g�m�m�,�'�K�	�w�w�~�~�k�"�
�	�	�+����+�.�E�	�K�K�M��=�=�?�D��H�H�Jr�__main__)r]�__all__r$r'r�os.pathrrBr
�sys�
gi.repositoryr�	getLoggerr�objectrrfrZr^rr�<module>rnsg���0����	��
���
���g���0�1��r�6�r�j�"�z��	�G�r

Zerion Mini Shell 1.0