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

�

+�c0����dZddlZddlmZddlmZddlZddlmZddl	Z	ddl
mZmZddl
Z
ddlZddlmZddlmZdd	lmZmZmZmZdd
lmZmZddlmZddlmZmZdd
l m!Z!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*gd�Z+Gd�d�Z,d�Z-d�Z.Gd�d�Z/Gd�de/�Z0Gd�de!�Z1d�Z2d#de
jfd�Z3	d$de0fd �Z4e5d!k(re4�Z6e7d"e6jp�yy)%z'Synchronous IO wrappers around jeepney
�N)�deque)�
ECONNRESET)�count)�DefaultSelector�
EVENT_READ)�Optional)�warn)�Parser�Message�MessageType�HeaderFields)�
Authenticator�BEGIN)�get_bus)�FileDescriptor�fds_buf_size)�	ProxyBase�
unwrap_msg)�Router)�message_bus�)�MessageFilters�FilterHandle�check_replyable)�open_dbus_connection�DBusConnection�Proxyc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�_Futurec��d|_y�N��_result��selfs �5/usr/lib/python3/dist-packages/jeepney/io/blocking.py�__init__z_Future.__init__ s	�����c�,�t|j�Sr!)�boolr#r$s r&�donez_Future.done#s���D�L�L�!�!r(c��d|f|_y�NFr")r%�	exceptions  r&�
set_exceptionz_Future.set_exception&s���y�)��r(c��d|f|_y)NTr")r%�results  r&�
set_resultz_Future.set_result)s
���f�~��r(c�,�|j\}}|r|S|�r!r")r%�success�values   r&r1z_Future.result,s����������L��r(N)�__name__�
__module__�__qualname__r'r+r/r2r1�r(r&rrs���"�*�&�r(rc�6�|�tj�|zSyr!)�time�	monotonic��timeouts r&�timeout_to_deadliner?3s�����~�~��'�)�)�r(c�J�|�!t|tj�z
d�Sy)Ng)�maxr;r<)�deadlines r&�deadline_to_timeoutrC8s$�����8�d�n�n�.�.��3�3�r(c��eZdZdZddejfd�Zd�Zd�Zdede	e
ejffd�Zd	�Z
d
�Zdd�Zd
�Zd�Zy)�DBusConnectionBasez8Connection machinery shared by this module and threading�sockc���||_||_t�|_t	d��|_t
�|_|jj|t�|_
d|_y)Nr)�start)rF�
enable_fdsr
�parserr�outgoing_serialr�selector�registerr�
select_key�unique_name)r%rFrIs   r&r'zDBusConnectionBase.__init__@sO����	�$����h���$�1�~���'�)��
��-�-�0�0��z�B�����r(c��|Sr!r9r$s r&�	__enter__zDBusConnectionBase.__enter__Is���r(c�$�|j�yr-)�close)r%�exc_type�exc_val�exc_tbs    r&�__exit__zDBusConnectionBase.__exit__Ls���
�
��r(�message�returnc��|�t|j�}|jrtjd�nd}|j	||��}||fS)N�i)�serial�fds)�nextrKrI�array�	serialise)r%rXr\r]�datas     r&�
_serialisezDBusConnectionBase._serialisePsL���>��$�.�.�/�F�"&�/�/�e�k�k�#��t��� � ��C� �8���S�y�r(c���|jj|gtjtj|fg�}|t|�kr|jj
||d�yyr!)rF�sendmsg�socket�
SOL_SOCKET�
SCM_RIGHTS�len�sendall)r%rar]�
bytes_sents    r&�_send_with_fdsz!DBusConnectionBase._send_with_fdsWs_���Y�Y�&�&�
�F�f�'�'��):�):�C�@�A�
�
�
��D�	�!��I�I���d�:�;�/�0�"r(c��	|jj�}|�|S|jt|���\}}|jj	||���Z)Nr=)r])rJ�get_next_message�_read_some_datarC�add_data)r%rB�msg�br]s     r&�_receivezDBusConnectionBase._receive`sZ����+�+�.�.�0�C����
��)�)�2E�h�2O�)�P�F�A�s��K�K� � ��� �,�
r(Nc��|jj|�D]Z\}}||jk(s�|jr|j	�cSt|jjd��gfcSt�)Ni)	rL�selectrNrI�_read_with_fds�unwrap_readrF�recv�TimeoutError)r%r>�key�evs    r&rnz"DBusConnectionBase._read_some_dataism���}�}�+�+�G�4�	A�G�C���d�o�o�%��?�?��.�.�0�0�&�t�y�y�~�~�d�';�<�b�@�@�	A��r(c�&�|jj�}|jj|t	��\}}}}|ttdd�zr|j�td��t|�tj|�fS)N�
MSG_CTRUNCrz&Unable to receive all file descriptors)rJ�
bytes_desiredrF�recvmsgr�getattrrerS�RuntimeErrorrvr�from_ancdata)r%�nbytesra�ancdata�flags�_s      r&ruz!DBusConnectionBase._read_with_fdsssv�����*�*�,��"&�)�)�"3�"3�F�L�N�"K���g�u�a��7�6�<��3�3��J�J�L��G�H�H��4� �.�"=�"=�g�"F�F�Fr(c�l�|jj�|jj�y)zClose the connectionN)rLrSrFr$s r&rSzDBusConnectionBase.close{s ���
�
�����	�	���r(�Fr!)r6r7r8�__doc__rer'rQrWr�bytesrr_rbrkrrrnrurSr9r(r&rErE>sZ��B� �V�]�]� ����'��u�h�u�{�{�>S�6T��1�-��G�r(rEc���eZdZddejf�fd�
Zed��Zddefd�ZeZ	dd�defd	�Z
dd�d
�Zddd�d�Zdd
d�de
efd�Zdd�defd�Z�xZS)rrFc����t�|�||�tt�|_t�|_tt|�|_	|jj�}|d|_y)Nr)�superr'rr�_routerr�_filtersrr�	bus_proxy�HellorO)r%rFrI�hello_reply�	__class__s    �r&r'zDBusConnection.__init__�sW���
����z�*��g����&�(��
��{�D�1����n�n�*�*�,��&�q�>��r(c�4�tdd��|jS)Nz@conn.router is deprecated, see the docs for APIs to use instead.���
stacklevel)r	r�r$s r&�routerzDBusConnection.router�s���
O��	��|�|�r(NrXc��|j||�\}}|r|j||�y|jj|�y)z.Serialise and send a :class:`~.Message` objectN)rbrkrFri)r%rXr\rar]s     r&�sendzDBusConnection.send�s;���O�O�G�V�4�	��c������c�*��I�I���d�#r(r=rYc�6�|jt|��S)a+Return the next available message from the connection

        If the data is ready, this will return immediately, even if timeout<=0.
        Otherwise, it will wait for up to timeout seconds, or indefinitely if
        timeout is None. If no message comes in time, it raises TimeoutError.
        )rrr?)r%r>s  r&�receivezDBusConnection.receive�s���}�}�0��9�:�:r(c���|j|��}|jj|�|jj	|�D]}|j
j
|��y)z\Receive one message and apply filters

        See :meth:`filter`. Returns nothing.
        r=N)r�r��incomingr��matches�queue�append)r%r>rp�filters    r&�
recv_messageszDBusConnection.recv_messages�sV��
�l�l�7�l�+�������c�"��m�m�+�+�C�0�	%�F��L�L����$�	%r()r>�unwrapc��t|�t|�}|�d}n
tdd��t|j�}|j||��	|j
t|���}|jjjtjd�}||k(r|rt|�S|S|jj|�|j j#|�D]}|j$j'|����)z�Send a message, wait for the reply and return it

        Filters are applied to other messages received before the reply -
        see :meth:`add_filter`.
        FzePassing unwrap= to .send_and_get_reply() is deprecated and will break in a future version of Jeepney.r�r�)r\r=���)rr?r	r^rK�send_messager�rC�header�fields�getr
�reply_serialrr�r�r�r�r�r�)	r%rXr>r�rBr\�msg_in�reply_tor�s	         r&�send_and_get_replyz!DBusConnection.send_and_get_reply�s���	�� �&�w�/���>��F��>�JK�
M��d�*�*�+�����'�&��1���\�\�*=�h�*G�\�H�F��}�}�+�+�/�/��0I�0I�2�N�H��6�!��%�f�-�-��
�
�L�L�!�!�&�)��-�-�/�/��7�
,�����#�#�F�+�
,�r(r)r��bufsizer�c�L�|�t|��}t|j||�S)a�Create a filter for incoming messages

        Usage::

            with conn.filter(rule) as matches:
                # matches is a deque containing matched messages
                matching_msg = conn.recv_until_filtered(matches)

        :param jeepney.MatchRule rule: Catch messages matching this rule
        :param collections.deque queue: Matched messages will be added to this
        :param int bufsize: If no deque is passed in, create one with this size
        )�maxlen)rrr�)r%�ruler�r�s    r&r�zDBusConnection.filter�s&���=���)�E��D�M�M�4��7�7r(c��t|�}t|�dk(r*|jt|���t|�dk(r�*|j	�S)aZProcess incoming messages until one is filtered into queue

        Pops the message from queue and returns it, or raises TimeoutError if
        the optional timeout expires. Without a timeout, this is equivalent to::

            while len(queue) == 0:
                conn.recv_messages()
            return queue.popleft()

        In the other I/O modules, there is no need for this, because messages
        are placed in queues by a separate task.

        :param collections.deque queue: A deque connected by :meth:`filter`
        :param float timeout: Maximum time to wait in seconds
        rr=)r?rhr�rC�popleft)r%r�r>rBs    r&�recv_until_filteredz"DBusConnection.recv_until_filtered�sI�� '�w�/���%�j�A�o����':�8�'D��E��%�j�A�o��}�}��r(r�r!)r6r7r8rer'�propertyr�rr�r�r�r�r�rrr�r��
__classcell__�r�s@r&rr�s����
*�V�]�]�
*�����
$�G�$��L�!%�;�'�;�(,�%�6:�$�,�<7;�A�8�X�e�_�8�"59��W�r(rc�4��eZdZdZdd��fd�
Zd�Zd�Z�xZS)rajA blocking proxy for calling D-Bus methods

    You can call methods on the proxy object, such as ``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.

    You can set a time limit on a call by passing ``_timeout=`` in the method
    call, or set a default when creating the proxy. The ``_timeout`` argument
    is not passed to the message generator.
    All timeouts are in seconds, and :exc:`TimeoutErrror` is raised if it
    expires before a reply arrives.

    :param msggen: A message generator object
    :param ~blocking.DBusConnection connection: Connection to send and receive messages
    :param float timeout: Default seconds to wait for a reply, or None for no limit
    Nr=c�@��t�|�|�||_||_yr!)r�r'�_connection�_timeout)r%�msggen�
connectionr>r�s    �r&r'zProxy.__init__s���
���� �%�����
r(c�z�|j�dnd|j��}d|j�d|j�|�d�S)N�z
, timeout=zProxy(z, �))r��_msggenr�)r%�extras  r&�__repr__zProxy.__repr__
sA���}�}�,��Z��
�
��3O������~�R��(8�(8�'9�%���B�Br(c�F���tj����fd��}|S)Nc����|jd�j�}�|i|��}|jjtj
usJ�t
�jj||���S)Nr�r=)	�popr�r��message_typer�method_callrr�r�)�args�kwargsr>rp�make_msgr%s    ��r&�innerz!Proxy._method_call.<locals>.innerso����j�j��T�]�]�;�G��D�+�F�+�C��:�:�*�*�k�.E�.E�E�E�E��d�.�.�A�A��W�B���
r()�	functools�wraps)r%r�r�s`` r&�_method_callzProxy._method_calls%���	����	"�	�
#�	��r()r6r7r8r�r'r�r�r�r�s@r&rr�s����"7;� �
C�
r(rc�X�|s'tttjt���|S)z�Raise ConnectionResetError from an empty read.

    Sometimes the socket raises an error itself, sometimes it gives no data.
    I haven't worked out when it behaves each way.
    )�ConnectionResetErrorr�os�strerror)rqs r&rvrvs"��
�"�:�r�{�{�:�/F�G�G��Hr(rYc	�&���tjtj���t|����fd�}	|�j|�t	|��}|D]@}|�j
|�|j
t|�jd����B|�j
t��jd��S#tj$r%}�j�td|�d��|�d}~w�j��xYw)z=Create a socket and authenticate ready to send D-Bus messages)�familyc�B���jt���||�Sr!)�
settimeoutrC)�methr�rBrFs  ��r&�with_sock_deadlinez'prep_socket.<locals>.with_sock_deadline1s������+�H�5�6��T�{�r()rIizDid not authenticate in z secondsN)re�AF_UNIXr?�connectrri�feedrvrwrr>rSrxr�)	�addrrIr>r��authr�req_data�erBrFs	       @@r&�prep_socketr�)s�����=�=����/�D�
#�7�+�H����4�<�<��.���4���	I�H��t�|�|�X�6��J�J�{�#5�d�i�i��#F�G�H�	I�	�4�<�<��/�	�O�O�D���K���>�>�P��
�
���5�g�Y�h�G�H�a�O����
�
��
�s�A;C�D� C:�:Dc�P�t|�}t|||��}t||�}|S)aConnect to a D-Bus message bus

    Pass ``enable_fds=True`` to allow sending & receiving file descriptors.
    An error will be raised if the bus does not allow this. For simplicity,
    it's advisable to leave this disabled unless you need it.

    D-Bus has an authentication step before sending or receiving messages.
    This takes < 1 ms in normal operation, but there is a timeout so that client
    code won't get stuck if the server doesn't reply. *auth_timeout* configures
    this timeout in seconds.
    r=)rr�r)�busrI�auth_timeout�bus_addrrF�conns      r&rrGs,���s�|�H��x��\�B�D��$�
�+�D��Kr(�__main__zUnique name:)Fg@)�SESSIONFg�?)9r�r_�collectionsr�errnorr��	itertoolsrr��	selectorsrrrer;�typingr�warningsr	�jeepneyr
rrr
�jeepney.authrr�jeepney.busr�jeepney.fdsrr�jeepney.wrappersrr�jeepney.routingr�jeepney.bus_messagesr�commonrrr�__all__rr?rCrErrrvr�rr6r��printrOr9r(r&�<module>r�s���������	�1�
����>�>�-��4�2�"�,�A�A�����(�
�@�@�Fr�'�r�j%�I�%�P
���
�
��>79����*�z���!�D�	�.�$�*�*�+�r(

Zerion Mini Shell 1.0