%PDF- %PDF-
Mini Shell

Mini Shell

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

�

+�c�����ddlZddlZddlmZddlmZddlmZmZddl	m
Z
ddlmZm
Z
mZddlmZmZddlmZd	d
lmZmZmZmZmZGd�d�Zdd
�ZGd�d�ZGd�d�ZGd�de�Zy)�N)�count)�Optional)�
Authenticator�BEGIN)�get_bus)�Message�MessageType�Parser)�	ProxyBase�
unwrap_msg)�message_bus�)�MessageFilters�FilterHandle�ReplyMatcher�RouterClosed�check_replyablec�x�eZdZdZdej
dejfd�Zdd�defd�Z	d	efd
�Z
d�Zd�Zd
�Z
y)�DBusConnectionaPA 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`.
    �reader�writerc��||_||_t�|_t	d��|_d|_tj�|_	y)Nr)�start)
rrr
�parserr�outgoing_serial�unique_name�asyncio�Lock�	send_lock)�selfrrs   �4/usr/lib/python3/dist-packages/jeepney/io/asyncio.py�__init__zDBusConnection.__init__s:���������h���$�1�~������ ������N��serial�messagec��RK�|j4�d{���|�t|j�}|jj	|j|��|jj
��d{���ddd��d{���y7�x7�7�	#1�d{���7swYyxYw�w)z.Serialise and send a :class:`~.Message` objectN)r�nextrr�write�	serialise�drain�r r&r%s   r!�sendzDBusConnection.send s������>�>�	&�	&��~��d�2�2�3���K�K���g�/�/��7�8��+�+�#�#�%�%�%�		&�	&�	&��
&��		&��	&�	&�	&�sW�B'�B�B'�AB�6B�7B�;B'�B�B'�B�B'�B$�B�B$� B'�returnc���K�	|jj�}|�|S|jjd��d{���}|st�|jj|��e7�(�w)z5Return the next available message from the connectionNi)r�get_next_messager�read�EOFError�add_data)r �msg�bs   r!�receivezDBusConnection.receive(s`������+�+�.�.�0�C����
��k�k�&�&�t�,�,�A�����K�K� � ��#��
-�s�>A+�A)�)A+c��K�|jj�|jj��d{���y7��w)zClose the D-Bus connectionN)r�close�wait_closed�r s r!r8zDBusConnection.close4s,�����������k�k�%�%�'�'�'�s�8A�A�Ac��K�|S�w�N�r:s r!�
__aenter__zDBusConnection.__aenter__9���������c��@K�|j��d{���y7��wr<)r8�r �exc_type�exc_val�exc_tbs    r!�	__aexit__zDBusConnection.__aexit__<s�����j�j�l���s���)�__name__�
__module__�__qualname__�__doc__r�StreamReader�StreamWriterr"rr-r6r8r>rFr=r#r!rrsR���(�w�3�3�(�W�=Q�=Q�(�6:�&�'�&�
$�w�
$�(�
�r#rc���K�t|�}tj|��d{���\}}t�}|D]b}|j	|�|j��d{���|j
d��d{���}|std��|j|��d|j	t�|j��d{���t||�}t|�4�d{���}tjtt|�j�d��d{���}	|	d|_ddd��d{���|S7��7��7��7��7�c7�+7�#1�d{���7swY|SxYw�w)zHOpen a plain D-Bus connection

    :return: :class:`DBusConnection`
    Niz#Socket closed before authentication�
r)rr�open_unix_connectionrr)r+r1r2�feedrr�
DBusRouter�wait_for�Proxyr
�Hellor)
�bus�bus_addrrr�authr�req_datar5�conn�router�
reply_bodys
          r!�open_dbus_connectionr\@sG����
�s�|�H�"�7�7��A�A�N�F�F�
�O�E�������X���l�l�n����+�+�d�#�#����@�A�A�
�
�
�1�
�
��L�L���
�,�,�.����&�&�)�D��$��)�)�6�"�+�+�E�+�v�,F�,L�,L�,N�PR�S�S�
�%�a�=���)�)��K�1B��	��#����)��S��)��)�)�)��K�s��$E'�E�:E'�!E�"E'�:E�;AE'�E	�E'�'E�(E'�+6E�!E
�"E�0E'�;E�<E'�E'�E'�	E'�E'�
E�E'�E$�E�E$�E'c��eZdZdZdZdZdZdefd�Ze	d��Z
dd�d�Zdefd	�Z
dd
d�deej fd
�Zd�Zd�Zdefd�Zd�Zy)rQz�A 'client' D-Bus connection which can wait for a specific reply.

    This runs a background receiver task, and makes it possible to send a
    request and wait for the relevant reply.
    NrYc��||_t�|_t�|_tj|j��|_yr<)	�_connr�_repliesr�_filtersr�create_task�	_receiver�	_rcv_task)r rYs  r!r"zDBusRouter.__init__js5����
�$���
�&�(��
� �,�,�T�^�^�-=�>��r#c�.�|jjSr<)r_rr:s r!rzDBusRouter.unique_nameps���z�z�%�%�%r#r$c��ZK�|jj||���d{���y7��w)z&Send a message, don't wait for a replyr$N)r_r-r,s   r!r-zDBusRouter.sendts �����j�j�o�o�g�f�o�5�5�5�s�!+�)�+r.c��K�t|�|jj�rtd��t	|j
j�}|jj|tj��5}|j||���d{���|�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).
        zThis DBusRouter has stoppedr$N)rrd�donerr(r_rr`�catchr�Futurer-)r r&r%�	reply_futs    r!�send_and_get_replyzDBusRouter.send_and_get_replyxs�����
	�� ��>�>��� ��<�=�=��d�j�j�0�0�1��
�]�]�
 �
 �����)9�
:�	%�i��)�)�G�F�)�3�3�3�#�O�	%�	%�3��#��	%�	%�sB�A>B?�B3�B/�	B3�!B1�"B3�%
B?�/B3�1B3�3B<�8B?r)�queue�bufsizermc�^�t|j||xstj|��S)arCreate a filter for incoming messages

        Usage::

            with router.filter(rule) as queue:
                matching_msg = await queue.get()

        :param MatchRule rule: Catch messages matching this rule
        :param asyncio.Queue queue: Send matching messages here
        :param int bufsize: If no queue is passed in, create one with this size
        )rrar�Queue)r �rulermrns    r!�filterzDBusRouter.filter�s%���D�M�M�4��1P�'�-�-��:P�Q�Qr#c��K�|S�wr<r=r:s r!r>zDBusRouter.__aenter__�r?r@c��FK�|jj�r|jj�y|jj�t	j
tj�5|j�d{���ddd�y7�
#1swYyxYw�w)NF)rdrh�result�cancel�
contextlib�suppressr�CancelledErrorrBs    r!rFzDBusRouter.__aexit__�sy�����>�>��� ��N�N�!�!�#�
�
�N�N�!�!�#��$�$�W�%;�%;�<�
%��n�n�$�$�
%��%��
%��s0�A3B!�5B�B�B�
	B!�B�B�B!r4c��|jj|�ryt|jj	|��D]}	|j
j
|�� y#tj$rY�7wxYw)zHandle one received messageN)	r`�dispatch�listra�matchesrm�
put_nowaitr�	QueueFull)r r4rrs   r!�	_dispatchzDBusRouter._dispatch�sk���=�=�!�!�#�&���4�=�=�0�0��5�6�	�F�
����'�'��,�	���$�$�
��
�s�A#�#A9�8A9c��K�		|jj��d{���}|j|��47�#|jj	�wxYw�w)z'Receiver loop - runs in a separate taskN)r_r6r�r`�drop_all)r r4s  r!rczDBusRouter._receiver�sJ����	%�� �J�J�.�.�0�0�����s�#��0��
�M�M�"�"�$�s�A�;�9�;�A�A)rGrHrIrJ�_nursery_mgr�_send_cancel_scope�_rcv_cancel_scoperr"�propertyrr-rrlrrrprrr>rFr�rcr=r#r!rQrQ`s����
�L�����?�^�?��&��&�-1�6�
%�7�
%�?C�A�R�X�g�m�m�%<�R���	�W�	�%r#rQc�,�eZdZdZdZdZdd�Zd�Zd�Zy)�open_dbus_routerz�Open a D-Bus 'router' to send and receive messages

    Use as an async context manager::

        async with open_dbus_router() as router:
            ...
    Nc��||_yr<)rU)r rUs  r!r"zopen_dbus_router.__init__�s	����r#c���K�t|j��d{���|_t|j�|_|jj��d{���S7�E7��wr<)r\rUrYrQ�req_ctxr>r:s r!r>zopen_dbus_router.__aenter__�sH����.�t�x�x�8�8��	�!�$�)�)�,����\�\�,�,�.�.�.�9��.�s"�A%�A!�AA%�A#�A%�#A%c��K�|jj|||��d{���|jj��d{���y7�'7��wr<)r�rFrYr8rBs    r!rFzopen_dbus_router.__aexit__�s@�����l�l�$�$�X�w��?�?�?��i�i�o�o����	@���s!�!A�A�!A�A
�A�
A��SESSION)	rGrHrIrJrYr�r"r>rFr=r#r!r�r��s"����D��G��/�
 r#r�c�.��eZdZdZ�fd�Zd�Zd�Z�xZS)rSa�An asyncio 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 ~asyncio.DBusRouter router: Router to send and receive messages.
    c�2��t�|�|�||_yr<)�superr"�_router)r �msggenrZ�	__class__s   �r!r"zProxy.__init__�s���
���� ���r#c�N�dj|j|j�S)Nz
Proxy({}, {}))�format�_msggenr�r:s r!�__repr__zProxy.__repr__�s���%�%�d�l�l�D�L�L�A�Ar#c������fd�}|S)Nc����K��|i|��}|jjtjusJ��jj|��d{���}t
|�S7��wr<)�header�message_typer	�method_callr�rlr)�args�kwargsr4�reply�make_msgr s    ��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$r=)r r�r�s`` r!�_method_callzProxy._method_call�s���	%��r#)rGrHrIrJr"r�r��
__classcell__)r�s@r!rSrS�s���	��B�r#rSr�)rrw�	itertoolsr�typingr�jeepney.authrr�jeepney.busr�jeepneyrr	r
�jeepney.wrappersrr�jeepney.bus_messagesr
�commonrrrrrrr\rQr�rSr=r#r!�<module>r�sa������-��0�0�2�,���
-�-�`�@V%�V%�p � �0�I�r#

Zerion Mini Shell 1.0