%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/jeepney/io/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/jeepney/io/__pycache__/trio.cpython-312.pyc

�

+�c:����ddlZddlmZddlZddlmZddlZddlmZ	ddlm	Z	ddlm
Z
mZddlZddlmZddlmZmZdd	lmZdd
lmZmZddlmZmZmZddlmZm Z dd
l!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(ejRe*�Z+gd�Z,ed��Z-Gd�de�Z.d!dd�de.fd�Z/Gd�de%�Z0Gd�d�Z1Gd�d�Z2Gd�de�Z3e	d!dd�d ��Z4y#e
$r	ddlm	Z	Y��wxYw)"�N)�contextmanager)�count)�Optional)�asynccontextmanager)�Value�Error)�Channel)�
Authenticator�BEGIN)�get_bus)�FileDescriptor�fds_buf_size)�Parser�MessageType�Message)�	ProxyBase�
unwrap_msg)�message_bus�)�MessageFilters�FilterHandle�ReplyMatcher�RouterClosed�check_replyable)�open_dbus_connection�open_dbus_router�Proxyc#�K�	d��y#t$rl}|jtjtjhvrt	j
d�d�t	jdj|��|�d}~wwxYw�w)Nzthis socket was already closedzsocket connection broken: {})�OSError�errno�EBADF�ENOTSOCK�trio�ClosedResourceError�BrokenResourceError�format)�excs �1/usr/lib/python3/dist-packages/jeepney/io/trio.py�)_translate_socket_errors_to_stream_errorsr)0so����	�
�����9�9����e�n�n�5�5��*�*�+K�L�RV�V��*�*�.�5�5�c�:���
���s%�B�	�B�	A>�A'A9�9A>�>Bc�r�eZdZdZdd�Zdd�defd�Zdefd�Zdde	fd	�Z
d
efd�Zd�Zd
�Z
d�Zed��Zy)�DBusConnectiona�A plain D-Bus connection with no matching of replies.

    This doesn't run any separate tasks: sending and receiving are done in
    the task that calls those methods. It's suitable for implementing servers:
    several worker tasks can receive requests and send replies.
    For a typical client pattern, see :class:`DBusRouter`.

    Implements trio's channel interface for Message objects.
    c���||_||_t�|_t	d��|_d|_tj�|_	tj�|_
d|_y)Nr)�start)�socket�
enable_fdsr�parserr�outgoing_serial�unique_namer#�Lock�	send_lock�	recv_lock�_leftover_to_send)�selfr.r/s   r(�__init__zDBusConnection.__init__IsO�����$����h���$�1�~������������������!%���N��serial�messagec��ZK�|j4�d{���|�t|j�}|jrt	jd�nd}|j||��}|j
||��d{���ddd��d{���y7�|7�7�	#1�d{���7swYyxYw�w)z.Serialise and send a :class:`~.Message` objectN�i)�fds)r4�nextr1r/�array�	serialise�
_send_data)r7r<r;r?�datas     r(�sendzDBusConnection.sendSs������>�>�	-�	-��~��d�2�2�3��&*�o�o�%�+�+�c�"�4�C��$�$�V��$�5�D��/�/�$��,�,�,�	-�	-�	-��

-��	-��	-�	-�	-�sW�B+�B�B+�A#B�:B�;B�?B+�
B�B+�B�B+�B(�B�B(�$B+rDc��K�|jjrtjd��t	�5|j
r#|j
|j
��d{���t|�5}|rZ|jj|gtjjtjj|fg��d{���}n#|jj|��d{���}|j
||��d{���ddd�ddd�y7��7�U7�37�#1swY�xYw#1swYyxYw�w)Nz!can't send data after sending EOF)r.�did_shutdown_SHUT_WRr#r$r)r6�_send_remainder�
memoryview�sendmsg�
SOL_SOCKET�
SCM_RIGHTSrE)r7rDr?�sents    r(rCzDBusConnection._send_data^s�����;�;�+�+��*�*�+N�O�O�
6�
8�
	7��%�%��*�*�4�+A�+A�B�B�B��D�!�
7�T��!%���!4�!4�d�V����.�.����0F�0F��?�>�"��D�"&���!1�!1�$�!7�7�D��*�*�4��6�6�6�
7�
	7�
	7�C����8��6��
7�
7��
	7�
	7�s}�6D>�+D2�#D�$D2�3AD&�
D �#D&�.D"�/D&�D$�	D&�
D2�	D>�D2� D&�"D&�$D&�&D/	�+D2�2D;�7D>c��"K�	|t|�krE||d5}|jj|��d{���}ddd�|z
}|t|�kr�Ed|_y7�(#1swY�'xYw#tj
$r||d|_�wxYw�w�N)�lenr.rEr6r#�	Cancelled)r7rD�already_sent�	remainingrMs     r(rHzDBusConnection._send_remainderqs�����	���T��*��,�-�(�=�I�!%���!1�!1�)�!<�<�D�=���$����T��*�&*�D�"�=��=�=���~�~�	�&*�,�-�%8�D�"��	�sH�B�A-�A!�A�A!�A-�A-�B�A!�!A*�&A-�-B�B�returnc��hK�|j4�d{���	|jj�}|�|cddd��d{���S|j��d{���\}}|st	j
d��|jj
||��~7��7�V7�?#1�d{���7swYyxYw�w)z5Return the next available message from the connectionNzSocket closed at the other end)r5r0�get_next_message�
_read_datar#�EndOfChannel�add_data)r7�msg�br?s    r(�receivezDBusConnection.receives������>�>�	-�	-���k�k�2�2�4���?��		-�	-�	-� $���0�0���3���+�+�,L�M�M����$�$�Q��,��	-��	-��1��	-�	-�	-�sa�B2�B�B2�B�B2�B�B2�B�B�;B�B2�B2�B�B/�#B&�$B/�+B2c��0K�|jr�|jj�}t�5|jj|t
���d{���\}}}}ddd�ttjdd�zr|j�td��tj�fSt�5|jjd��d{���}ddd�|gfS7��#1swY��xYw7�#1swYgfSxYw�w)N�
MSG_CTRUNCrz&Unable to receive all file descriptorsi)r/r0�
bytes_desiredr)r.�recvmsgr�getattrr#�_close�RuntimeErrorr
�from_ancdata�recv)r7�nbytesrD�ancdata�flags�_s      r(rWzDBusConnection._read_data�s������?�?��[�[�.�.�0�F�:�<�
�04���0C�0C��L�N�1�+�'��g�u�a�
��w�t�{�{�L�!�<�<����
�"�#K�L�L���4�4�W�=�=�=�;�<�
4�!�[�[�-�-�d�3�3��
4���8�O�+��
�
��4��
4���8�O�sY�1D�(C9�C7�	C9�%A"D�D�&D�'D�+D�7C9�9D�>D�D�D�
Dc�F�|jj�d|_yrO)r.�closer6�r7s r(rbzDBusConnection._close�s��������!%��r9c��,K�|j�y�w)zClose the D-Bus connectionN)rbrls r(�aclosezDBusConnection.aclose�s�������
�s�c�`K�tj�4�d{���}t|�}|j|��d{���	|���|j	��d{���ddd��d{���y7�W7�57�#|j	��d{���7wxYw7�)#1�d{���7swYyxYw�w)aYTemporarily wrap this connection as a :class:`DBusRouter`

        To be used like::

            async with conn.router() as req:
                reply = await req.send_and_get_reply(msg)

        While the router is running, you shouldn't use :meth:`receive`.
        Once the router is closed, you can use the plain connection again.
        N)r#�open_nursery�
DBusRouterr-rn)r7�nursery�routers   r(rszDBusConnection.router�s������$�$�&�	&�	&�'���%�F��,�,�w�'�'�'�
&����m�m�o�%�%�
	&�	&�	&��'��&��f�m�m�o�%�%��
	&��	&�	&�	&�s��B.�A3�B.� B�A5�B�A9�
B�A7�B�"B.�-B�.B.�5B�7B�9B�
B
�B�B�B.�B+�B"� B+�'B.)F)r)�__name__�
__module__�__qualname__�__doc__r8rrE�bytesrCrIrHr\rWrbrnrrs�r9r(r+r+?sd���&�6:�-�'�-�7�U�7�&�*��
-�w�
-��"&�
��&��&r9r+F�r/rTc��K�t|�}tj|��d{���}t|��}|D]B}|j	|��d{���|j|j
��d{�����D|j	t��d{���t|j|��}|j�4�d{���}|jtj���d{���}|jd|_ddd��d{���|S7��7��7��7��7�]7�47�#1�d{���7swY|SxYw�w)zHOpen a plain D-Bus connection

    :return: :class:`DBusConnection`
    Nrzr)rr#�open_unix_socketr
�send_all�feed�receive_somerr+r.rs�send_and_get_replyr�Hello�bodyr2)	�busr/�bus_addr�sock�authr�req_data�connrs�replys	         r(rr�s����
�s�|�H�%)�%:�%:�8�%D�D�D�
�Z�0�E��.���m�m�H�%�%�%�
�
�
��*�*�,�,�-�.��-�-��
����$�+�+�*�=�D��{�{�}�)�)���/�/��0A�0A�0C�D�D�� �:�:�a�=���)�)��K�# E��
	&��,����)��D��)��)�)�)��K�s��$E�D�)E�D�"E�3D 
�4"E�D"�/E�D$�E�
'D*�1D&�2D*�
E�D(�E�E� E�"E�$E�&D*�(E�*D=�0D3�1D=�8Ec�F��eZdZdef�fd�Zed��Zd�Zd�Zd�Z	�xZ
S)�TrioFilterHandle�filtersc�6��t�|�|||�||_yrO)�superr8�send_channel)r7r��rule�send_chn�recv_chn�	__class__s     �r(r8zTrioFilterHandle.__init__�s���
����$��1�$��r9c��|jSrO��queuerls r(�receive_channelz TrioFilterHandle.receive_channel�s���z�z�r9c��tK�|j�|jj��d{���y7��wrO)rkr�rnrls r(rnzTrioFilterHandle.aclose�s'�����
�
�����&�&�(�(�(�s�.8�6�8c��"K�|jS�wrOr�rls r(�
__aenter__zTrioFilterHandle.__aenter__�s�����z�z��s�
c��@K�|j��d{���y7��wrO)rn)r7�exc_type�exc_val�exc_tbs    r(�	__aexit__zTrioFilterHandle.__aexit__�s�����k�k�m���s���)rtrurvrr8�propertyr�rnr�r��
__classcell__�r�s@r(r�r��s2���%��%�����)��r9r�c�(�eZdZdZd�Zd�Zd�Zd�Zy)�Futurez4A very simple Future for trio based on `trio.Event`.c�D�d|_tj�|_yrO)�_outcomer#�Event�_eventrls r(r8zFuture.__init__�s����
��j�j�l��r9c�X�t|�|_|jj�yrO)rr�r��set)r7�results  r(�
set_resultzFuture.set_result�s���f�
��
������r9c�X�t|�|_|jj�yrO)rr�r�r�)r7r's  r(�
set_exceptionzFuture.set_exception�s���c�
��
������r9c��K�|jj��d{���|jj�S7��wrO)r��waitr��unwraprls r(�getz
Future.get�s4�����k�k��� � � ��}�}�#�#�%�%�	!�s�A�?�AN)rtrurvrwr8r�r�r�ryr9r(r�r��s��>�#���&r9r�c���eZdZdZdZdZdefd�Zed��Z	dd�d�Z
defd	�Zdd
d�de
ejfd
�Zdej"fd�Zd�Zdefd�Zej*fd�Zy)rqz�A client D-Bus connection which can wait for replies.

    This runs a separate receiver task and dispatches received messages.
    Nr�c�N�||_t�|_t�|_yrO)�_connr�_repliesr�_filters)r7r�s  r(r8zDBusRouter.__init__s����
�$���
�&�(��
r9c�.�|jjSrO)r�r2rls r(r2zDBusRouter.unique_names���z�z�%�%�%r9r:c��ZK�|jj||���d{���y7��w)z/Send a message, don't wait for a reply
        r:N)r�rE)r7r<r;s   r(rEzDBusRouter.sends"�����j�j�o�o�g�f�o�5�5�5�s�!+�)�+rTc��nK�t|�|j�td��t|jj
�}|jj|t��5}|j||���d{���|j��d{���cddd�S7�%7�#1swYyxYw�w)z�Send a method call message and wait for the reply

        Returns the reply message (method return or error message type).
        NzThis DBusRouter has stoppedr:)r�_rcv_cancel_scoperr@r�r1r��catchr�rEr�)r7r<r;�	reply_futs    r(r�zDBusRouter.send_and_get_replys�����
	�� ��!�!�)��<�=�=��d�j�j�0�0�1��
�]�]�
 �
 ����
2�	+�i��)�)�G�F�)�3�3�3�#�-�-�/�)�	+�	+�3��)��	+�	+�sB�A&B5�(B)�?B%�B)�B'�B)�
B5�%B)�'B)�)B2�.B5r)�channel�bufsizer�c�l�|�tj|�\}}nd}t|j|||�S)aCreate a filter for incoming messages

        Usage::

            async with router.filter(rule) as receive_channel:
                matching_msg = await receive_channel.receive()

            # OR:
            send_chan, recv_chan = trio.open_memory_channel(1)
            async with router.filter(rule, channel=send_chan):
                matching_msg = await recv_chan.receive()

        If the channel fills up,
        The sending end of the channel is closed when leaving the ``async with``
        block, whether or not it was passed in.

        :param jeepney.MatchRule rule: Catch messages matching this rule
        :param trio.MemorySendChannel channel: Send matching messages here
        :param int bufsize: If no channel is passed in, create one with this size
        N)r#�open_memory_channelr�r�)r7r�r�r��recv_channels     r(�filterzDBusRouter.filter#s8��*�?�$(�$<�$<�W�$E�!�G�\��L���
�
�t�W�l�K�Kr9rrc��K�|j�td��|j|j��d{���|_y7�
�w)Nz+DBusRouter receiver task is already running)r�rcr-�	_receiver)r7rrs  r(r-zDBusRouter.start@s9�����!�!�-��L�M�M�'.�}�}�T�^�^�'D�!D���!D�s�6A�A�Ac��K�|j�!|jj�d|_tjd��d{���y7��w)z Stop the sender & receiver tasksNr)r��cancelr#�sleeprls r(rnzDBusRouter.acloseEsA�����!�!�-��"�"�)�)�+�%)�D�"��j�j��m���s�AA�A�	ArZc���|jj|�ry|jj|�D]}	|jj|�� y#tj$rY�7wxYw)zHandle one received messageN)r��dispatchr��matchesr��send_nowaitr#�
WouldBlock)r7rZr�s   r(�	_dispatchzDBusRouter._dispatchRsf���=�=�!�!�#�&���m�m�+�+�C�0�	�F�
��#�#�/�/��4�	���?�?�
��
�s�A�A0�/A0c	��4K�tj�5}d|_|j|�		|jj��d{���}|j
|��47�#d|_|jj�tjd�5}|jjj�D],}d|_
|jj��d{���7�.	ddd�w#1swYwxYwxYw#1swYyxYw�w)z'Receiver loop - runs in a separate taskTNF�)r#�CancelScope�
is_running�startedr�r\r�r��drop_all�
move_on_afterr�r��values�shieldr�rn)r7�task_status�cscoperZ�
cleanup_scoper�s      r(r�zDBusRouter._receiver]s�����
�
�
�
�	;�6�"�D�O�����'�
;�� $�
�
� 2� 2� 4�4�C��N�N�3�'��4��#(����
�
�&�&�(��'�'��*�;�m�"&�-�-�"7�"7�">�">�"@�;��/3�
�,�$�1�1�8�8�:�:�:�;�;�;�;��	;�	;�sX�D�D�A(�A&�A(�(7D	�AC=	�+C.�,C=	�4	D	�=D
�D	�	D�D�D)rtrurvrw�_nursery_mgrr�r+r8r�r2rErr�rr#�MemorySendChannelr��Nurseryr-rnr��TASK_STATUS_IGNOREDr�ryr9r(rqrq�s�����L���)�^�)�
�&��&�-1�6�

+�7�
+�IM�VW�L�x��0F�0F�'G�L�:E�4�<�<�E�
	�	�W�	�+/�*B�*B�;r9rqc�(��eZdZdZ�fd�Zd�Z�xZS)ra�A trio proxy for calling D-Bus methods

    You can call methods on the proxy object, such as ``await bus_proxy.Hello()``
    to make a method call over D-Bus and wait for a reply. It will either
    return a tuple of returned data, or raise :exc:`.DBusErrorResponse`.
    The methods available are defined by the message generator you wrap.

    :param msggen: A message generator object.
    :param ~trio.DBusRouter router: Router to send and receive messages.
    c�h��t�|�|�t|t�st	d��||_y)Nz)Proxy can only be used with DBusRequester)r�r8�
isinstancerq�	TypeError�_router)r7�msggenrsr�s   �r(r8zProxy.__init__~s-���
���� ��&�*�-��G�H�H���r9c������fd�}|S)Nc����K��|i|��}|jjtjusJ��jj|��d{���}t
|�S7��wrO)�header�message_typer�method_callr�r�r)�args�kwargsrZr��make_msgr7s    ��r(�innerz!Proxy._method_call.<locals>.inner�s[������D�+�F�+�C��:�:�*�*�k�.E�.E�E�E�E��,�,�9�9�#�>�>�E��e�$�$�?�s�AA$�A"�A$ry)r7r�r�s`` r(�_method_callzProxy._method_call�s���	%��r9)rtrurvrwr8r�r�r�s@r(rrss���	��r9rc�0K�t||���d{���}|4�d{���|j�4�d{���}|���ddd��d{���ddd��d{���y7�N7�E7�.7�#1�d{���7swY�+xYw7�"#1�d{���7swYyxYw�w)a�Open a D-Bus 'router' to send and receive messages.

    Use as an async context manager::

        async with open_dbus_router() as req:
            ...

    :param str bus: 'SESSION' or 'SYSTEM' or a supported address.
    :return: :class:`DBusRouter`

    This is a shortcut for::

        conn = await open_dbus_connection()
        async with conn:
            async with conn.router() as req:
                ...
    rzN)rrs)r�r/r��rtrs    r(rr�s�����&&�c�j�A�A�D�����;�;�=�	�	�C��I�	�	����B����	��	��	�	�	�������s��B�A"�
B�A$�B�B�A&�B�A*�B�A(�
B�B�A?�B�$B�&B�(B�*A<	�0A3�1A<	�8B�?B�B�B
�B�B)�SESSION)5rA�
contextlibrr �	itertoolsr�logging�typingrr�ImportError�async_generator�outcomerrr#�trio.abcr	�jeepney.authr
r�jeepney.busr�jeepney.fdsr
r�jeepney.low_levelrrr�jeepney.wrappersrr�jeepney.bus_messagesr�commonrrrrr�	getLoggerrt�log�__all__r)r+rr�r�rqrrryr9r(�<module>rs����%�����4�.�!���-��4�:�:�2�,����g����!����&�
��
�{&�W�{&�|�E��n��4�|��(&�&�&r;�r;�j�I��6�������K�4�3�4�s�C�C,�+C,

Zerion Mini Shell 1.0