AlkantarClanX12

Your IP : 18.119.108.233


Current Path : /usr/lib64/python3.6/site-packages/dbus/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/dbus/__pycache__/connection.cpython-36.pyc

3

iR�V}l�@s�dZdZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZmZmZmZmZddlmZdd	lmZmZer�dd
lmZnddlmZejd�Zd
d�ZGdd�de �Z!Gdd�de�ZdS)�
Connection�SignalMatchZreStructuredText�N)r�LOCAL_IFACE�
LOCAL_PATH�validate_bus_name�validate_interface_name�validate_member_name�validate_object_path)�
DBusException)�ErrorMessage�HANDLER_RESULT_NOT_YET_HANDLED�MethodCallMessage�MethodReturnMessage�
SignalMessage)�ProxyObject)�is_py2�is_py3)�String)�
UTF8Stringzdbus.connectioncOsdS)N�)�args�kwargsrr�"/usr/lib64/python3.6/connection.py�_noop1src@s�eZdZddddddddd	d
ddd
ddddgZer<ejd�ee�Zd+dd�Zdd�Z	dd�Z
dd�Zedd��Z
dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdS),r�_sender_name_owner�_member�
_interface�_sender�_path�_handler�_args_match�_rule�_byte_arrays�
_conn_weakref�_destination_keyword�_interface_keyword�_message_keyword�_member_keyword�_sender_keyword�
_path_keyword�_int_args_match�
_utf8_stringsFNcKsl|dk	rt|�|dk	r t|�|dk	r0t|�|dk	r@t|�d|_tj|�|_||_||_	||_
||_||_||_
tr�|jdd�|_nd|kr�td��||_||_|	|_||_|
|_||_|
|_||_|s�d|_n�i|_x�|D]�}|jd��s�td|��yt|dd��}Wn"tk
�r4td|��YnX|dk�sJ|dk�rVtd	|��|||j|<q�WdS)
N�utf8_stringsFz*unexpected keyword argument 'utf8_strings'�argz(SignalMatch: unknown keyword argument %s�r�?z9SignalMatch: arg match index must be in range(64), not %d)rrrr	r!�weakref�refr#rrrrrrr�popr+�	TypeErrorr"r(r)r'r%r&r$r r*�
startswith�int�
ValueError)�self�conn�sender�object_path�dbus_interface�member�handler�byte_arraysZsender_keywordZpath_keywordZinterface_keywordZmember_keywordZmessage_keywordZdestination_keywordrZkwarg�indexrrr�__init__AsX
zSignalMatch.__init__cCstt|��S)z-SignalMatch objects are compared by identity.)�hash�id)r7rrr�__hash__|szSignalMatch.__hash__cCs||kS)z-SignalMatch objects are compared by identity.r)r7�otherrrr�__eq__�szSignalMatch.__eq__cCs||k	S)z-SignalMatch objects are compared by identity.r)r7rDrrr�__ne__�szSignalMatch.__ne__cCs|jS)N)r)r7rrr�<lambda>�szSignalMatch.<lambda>cCs�|jdkr�dg}|jdk	r*|jd|j�|jdk	rD|jd|j�|jdk	r^|jd|j�|jdk	rx|jd|j�|jdk	r�x(|jj�D]\}}|jd||f�q�Wdj|�|_|jS)Nz
type='signal'zsender='%s'z	path='%s'zinterface='%s'zmember='%s'z
arg%d='%s'�,)	r!r�appendrrrr*�items�join)r7Zruler?�valuerrr�__str__�s





zSignalMatch.__str__cCsd|jt|�|j|j�fS)Nz<%s at %x "%s" on conn %r>)�	__class__rBr!r#)r7rrr�__repr__�szSignalMatch.__repr__cCs
||_dS)N)r)r7�new_namerrr�set_sender_name_owner�sz!SignalMatch.set_sender_name_ownercKs\|d|jfkrdS||jkr dS||jkr.dS||jkr<dS||jkrJdS||jkrXdSdS)NFT)rrrrrr )r7r9r:r;r<r=rrrr�matches_removal_spec�s




z SignalMatch.matches_removal_specc
Cs�d}|jd|j�fkrdS|jdk	r�tdd�}tr6tnt}trFd|d<|jf|�}xB|jj	�D]4\}}|t
|�ks�t|||�s�|||kr^dSq^W|jd|j
�fkr�dS|jd|j�fkr�dS|jd|j�fkr�dSy�to�|j}|dks�|s�|j�r$t|jd�}t�r|j|d<|jf|�}i}|jdk	�rB|j�||j<|jdk	�r\|j�||j<|jdk	�rv|j�||j<|jdk	�r�|j
�||j<|jdk	�r�|j�||j<|jdk	�r�|||j<|j||�Wn"tj�tjddd�YnXdS)NFT)r>r,z&Exception in handler for D-Bus signal:�)�exc_info) rZ
get_senderr*�dictrrrr�
get_args_listrJ�len�
isinstancer�
get_memberr�
get_interfacer�get_pathr+r"r(r$Zget_destinationr)r'r%r&r�logging�basicConfig�_logger�error)r7�messagerrZarg_typer?rLr,rrr�maybe_handle_message�sZ




z SignalMatch.maybe_handle_messagecCs4|j�}|dk	r0|j||j|j|j|jf|j�dS)N)r#�remove_signal_receiverrrrrr )r7r8rrr�remove�s
zSignalMatch.remove)FNNNNNN)�__name__�
__module__�__qualname__Z_slotsrrI�tuple�	__slots__r@rCrErF�propertyr9rMrOrQrRrarcrrrrr5s.


7:cs~eZdZdZeZ�fdd�Zdd�Zddd	�Zdd
d�Z	dd
�Z
ddd�Zdd�Zdd�Z
d dd�Zd"dd�Zdd�Z�ZS)#rzzA connection to another application. In this base class there is
    assumed to be no bus daemon.

    :Since: 0.81.0
    csJtt|�j||�t|d�sFd|_g|_i|_tj�|_	|j
|jj�dS)N�_dbus_Connection_initializedrS)
�superrr@�hasattrrj�"_Connection__call_on_disconnection�!_signal_recipients_by_object_path�	threadingZLock�
_signals_lockZadd_message_filterrN�_signal_func)r7rr)rNrrr@s

zConnection.__init__cCs|S)aReturn the unique name for the given bus name, activating it
        if necessary and possible.

        If the name is already unique or this connection is not to a
        bus daemon, just return it.

        :Returns: a bus name. If the given `bus_name` exists, the returned
            name identifies its current owner; otherwise the returned name
            does not exist.
        :Raises DBusException: if the implementation has failed
            to activate the given bus name.
        :Since: 0.81.0
        r)r7�bus_namerrr�activate_name_ownerszConnection.activate_name_ownerNTcKsn|jdd�}|dk	rB|dk	r$td��ddlm}|dtdd�|}|r\td	d
j|j����|j||||d�S)a�Return a local proxy for the given remote object.

        Method calls on the proxy are translated into method calls on the
        remote object.

        :Parameters:
            `bus_name` : str
                A bus name (either the unique name or a well-known name)
                of the application owning the object. The keyword argument
                named_service is a deprecated alias for this.
            `object_path` : str
                The object path of the desired object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures

        :Returns: a `dbus.proxies.ProxyObject`
        �
named_serviceNz3bus_name and named_service cannot both be specifiedr)�warnziPassing the named_service parameter to get_object by name is deprecated: please use positional parameters�)�
stacklevelz4get_object does not take these keyword arguments: %sz, )�
introspect)r2r3�warningsru�DeprecationWarningrK�keys�ProxyObjectClass)r7rrr:rxrrtrurrr�
get_object$s

zConnection.get_objectc

Ks�|j�|jdd�}|dk	rJ|dk	r,td��|}ddlm}|dtdd�t||||||f|�}	|jj�z4|j	j
|i�}
|
j
|i�}|j
|g�}|j|	�Wd|jj�X|	S)	aArrange for the given function to be called when a signal matching
        the parameters is received.

        :Parameters:
            `handler_function` : callable
                The function to be called. Its positional arguments will
                be the arguments of the signal. By default it will receive
                no keyword arguments, but see the description of
                the optional keyword arguments below.
            `signal_name` : str
                The signal name; None (the default) matches all names
            `dbus_interface` : str
                The D-Bus interface name with which to qualify the signal;
                None (the default) matches all interface names
            `bus_name` : str
                A bus name for the sender, which will be resolved to a
                unique name if it is not already; None (the default) matches
                any sender.
            `path` : str
                The object path of the object which must have emitted the
                signal; None (the default) matches any object path
        :Keywords:
            `utf8_strings` : bool
                If True, the handler function will receive any string
                arguments as dbus.UTF8String objects (a subclass of str
                guaranteed to be UTF-8). If False (default) it will receive
                any string arguments as dbus.String objects (a subclass of
                unicode).
            `byte_arrays` : bool
                If True, the handler function will receive any byte-array
                arguments as dbus.ByteArray objects (a subclass of str).
                If False (default) it will receive any byte-array
                arguments as a dbus.Array of dbus.Byte (subclasses of:
                a list of ints).
            `sender_keyword` : str
                If not None (the default), the handler function will receive
                the unique name of the sending endpoint as a keyword
                argument with this name.
            `destination_keyword` : str
                If not None (the default), the handler function will receive
                the bus name of the destination (or None if the signal is a
                broadcast, as is usual) as a keyword argument with this name.
            `interface_keyword` : str
                If not None (the default), the handler function will receive
                the signal interface as a keyword argument with this name.
            `member_keyword` : str
                If not None (the default), the handler function will receive
                the signal name as a keyword argument with this name.
            `path_keyword` : str
                If not None (the default), the handler function will receive
                the object-path of the sending object as a keyword argument
                with this name.
            `message_keyword` : str
                If not None (the default), the handler function will receive
                the `dbus.lowlevel.SignalMessage` as a keyword argument with
                this name.
            `arg...` : unicode or UTF-8 str
                If there are additional keyword parameters of the form
                ``arg``\ *n*, match only signals where the *n*\ th argument
                is the value given for that keyword parameter. As of this
                time only string arguments can be matched (in particular,
                object paths and signatures can't).
            `named_service` : str
                A deprecated alias for `bus_name`.
        rtNz3bus_name and named_service cannot both be specifiedr)ruzrPassing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parametersrv)rw)
Z_require_main_loopr2r3ryrurzrrp�acquirern�
setdefaultrI�release)
r7Zhandler_function�signal_namer;rr�path�keywordsrtru�match�by_interface�	by_member�matchesrrr�add_signal_receiverIs(G


zConnection.add_signal_receiverccs�|dk	rd|f}nd}|dk	r(d|f}nd}|dk	r>d|f}nd}x~|D]v}|jj|�}|dkrbqHxZ|D]R}|j|d�}|dkr�qhx6|D].}|j|d�}	|	dkr�q�x|	D]
}
|
Vq�Wq�WqhWqHWdS)N)N)N)N)rn�get)r7r�r;r<Z	path_keysZinterface_keysZmember_keysr�r�r��mrrr�_iter_easy_matches�s.






zConnection._iter_easy_matchesc
Ks>|jdd�}|dk	rB|dk	r$td��|}ddlm}|dtdd�g}	g}
|jj�z�|jj|d�}|dkrpdS|j|d�}|dkr�dS|j|d�}
|
dkr�dSx@|
D]8}||ks�|j	|||||f|�r�|
j
|�q�|	j
|�q�W|	r�|	||<n ||=|�s||=|�s|j|=Wd|jj�Xx|
D]}|j|��q&WdS)Nrtz3bus_name and named_service cannot both be specifiedr)ruzuPassing the named_service parameter to remove_signal_receiver by name is deprecated: please use positional parametersrv)rw)
r2r3ryrurzrpr~rnr�rRrIr��_clean_up_signal_match)r7Zhandler_or_matchr�r;rrr�r�rtru�newZ	deletionsr�r�r�r�rrrrb�sT




z!Connection.remove_signal_receivercCsdS)Nr)r7r�rrrr�sz!Connection._clean_up_signal_matchcCs�t|t�stS|j�}|j�}|j�}x |j|||�D]}|j|�q6W|tkr�|t	kr�|dkr�xF|j
D]<}y||�Wqhtk
r�tj
�tjddd�YqhXqhWtS)zvD-Bus filter function. Handle signals by dispatching to Python
        callbacks kept in the match-rule tree.
        ZDisconnectedz-Exception in handler for Disconnected signal:rS)rT)rXrrrZr[rYr�rarrrm�	Exceptionr\r]r^r_)r7r`r;r�r�r��cbrrrrq	s&


zConnection._signal_funcg�?Fcs|tkrtdt��|tkr(tdt��t|
d��trH|jdd��d<nd|krXtd��t||||d�}
y|
j|d|i�Wn@t	k
r�}z$t
j�tj
d	|||j|��WYd
d
}~XnX�d
kr܈d
kr�|j|
�d
S�d
kr�t��d
kr�t����fdd�}|j|
||	|d
�S)aSCall the given method, asynchronously.

        If the reply_handler is None, successful replies will be ignored.
        If the error_handler is None, failures will be ignored. If both
        are None, the implementation may request that no reply is sent.

        :Returns: The dbus.lowlevel.PendingCall.
        :Since: 0.81.0
        z1Methods may not be called on the reserved path %sz6Methods may not be called on the reserved interface %s)r>r,Fz*unexpected keyword argument 'utf8_strings')�destinationr��	interface�method�	signaturez<Unable to set arguments %r according to signature %r: %s: %sNcsVt|t�r�|jf���n6t|t�rB�t|j�d|j�i��n�td|��dS)N�namez%Unexpected type for reply message: %r)rXrrVrr
Zget_error_namer3)r`)�
error_handler�
get_args_opts�
reply_handlerrr�msg_reply_handlerZs

z0Connection.call_async.<locals>.msg_reply_handler)�require_main_loop)rr
rrUrr�r3r
rIr�r\r]r^r_rNZsend_messagerZsend_message_with_reply)r7rrr:r;r�r�rr�r��timeoutr>r�rr`�er�r)r�r�r�r�
call_async'sB


	zConnection.call_asyncc	Ks|tkrtdt��|tkr(tdt��t|d�}
trH|	jdd�|
d<nd|	krXtd��t||||d�}y|j|d|i�Wn@t	k
r�}z$t
j�tj
d	|||j|��WYd
d
}~XnX|j||�}
|
jf|
�}t|�dkr�d
St|�dkr�|dSt|�Sd
S)
zECall the given method, synchronously.
        :Since: 0.81.0
        z1Methods may not be called on the reserved path %sz6Methods may not be called on the reserved interface %s)r>r,Fz*unexpected keyword argument 'utf8_strings')r�r�r�r�r�z<Unable to set arguments %r according to signature %r: %s: %sNrrS)rr
rrUrr�r3r
rIr�r\r]r^r_rNZ!send_message_with_reply_and_blockrVrWrg)r7rrr:r;r�r�rr�r>rr�r`r�Z
reply_messageZ	args_listrrr�
call_blockinggs<
zConnection.call_blockingcCs|jj|�dS)z�Arrange for `callable` to be called with one argument (this
        Connection object) when the Connection becomes
        disconnected.

        :Since: 0.83.0
        N)rmrI)r7�callablerrr�call_on_disconnection�sz Connection.call_on_disconnection)NNT)NNNN)NNNN��)r�FT��)r�F)rdrerf�__doc__rr|r@rsr}r�r�rbr�rqr�r�r��
__classcell__rr)rNrr�s*
&
`
7 
>
+)rr)"�__all__Z
__docformat__r\ror0Z_dbus_bindingsrZ_Connectionrrrrrr	Zdbus.exceptionsr
Z
dbus.lowlevelrrr
rrZdbus.proxiesrZdbus._compatrrrrZ	getLoggerr^r�objectrrrrr�<module>s"$
D