AlkantarClanX12

Your IP : 3.144.100.252


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

3

iR�V��@s:dZdZddlZddlZddlZddlZddlmZddlZdd	l	m
Z
mZmZm
Z
mZmZmZdd
lmZmZddlmZmZmZddlmZmZmZdd
lmZddlmZej d�Z!Gdd�de"�Z#Gdd�de"�Z$dd�Z%dd�Z&dd�Z'Gdd�de(�Z)e)de"fi�Z*e"�Z+Gdd�de*�Z,Gdd�de,�Z-dS)�BusName�Object�FallbackObject�method�signalZrestructuredtext�N)�Sequence)�INTROSPECTABLE_IFACE�
ObjectPath�
SessionBus�	Signature�Struct�validate_bus_name�validate_object_path)rr)�
DBusException�NameExistsException�UnknownMethodException)�ErrorMessage�MethodReturnMessage�MethodCallMessage)�
LOCAL_PATH)�is_py2zdbus.servicec@s(eZdZdZdd�Zdd�Zer$eZdS)�_VariantSignaturez�A fake method signature which, when iterated, yields an endless stream
    of 'v' characters representing variants (handy with zip()).

    It has no string representation.
    cCs|S)zReturn self.�)�selfrr�/usr/lib64/python3.6/service.py�__iter__8sz_VariantSignature.__iter__cCsdS)zReturn 'v' whenever called.�vr)rrrr�__next__<sz_VariantSignature.__next__N)�__name__�
__module__�__qualname__�__doc__rrr�nextrrrrr2s
rc@sFeZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	e	Z
dS)ra^A base class for exporting your own Named Services across the Bus.

    When instantiated, objects of this class attempt to claim the given
    well-known name on the given bus for the current process. The name is
    released when the BusName object becomes unreferenced.

    If a well-known name is requested multiple times, multiple references
    to the same BusName object will be returned.

    Caveats
    -------
    - Assumes that named services are only ever requested using this class -
      if you request names from the bus directly, confusion may occur.
    - Does not handle queueing.
    NFc
Cs�t|ddd�|dkr4ddl}|jdtdd�t�}||jkrH|j|S|rRtjpTd|r^tjp`dB|rltj	pndB}|j
||�}|tjkr�n<|tjkr�n0|tj
kr�t|��n|tjkr�ntd	||f��tj|�}	||	_||	_|	|j|<|	S)
aSConstructor, which may either return an existing cached object
        or a new object.

        :Parameters:
            `name` : str
                The well-known name to be advertised
            `bus` : dbus.Bus
                A Bus on which this service will be advertised.

                Omitting this parameter or setting it to None has been
                deprecated since version 0.82.1. For backwards compatibility,
                if this is done, the global shared connection to the session
                bus will be used.

            `allow_replacement` : bool
                If True, other processes trying to claim the same well-known
                name will take precedence over this one.
            `replace_existing` : bool
                If True, this process can take over the well-known name
                from other processes already holding it.
            `do_not_queue` : bool
                If True, this service will not be placed in the queue of
                services waiting for the requested name if another service
                already holds it.
        TF)Zallow_well_knownZallow_uniqueNrzKOmitting the "bus" parameter to dbus.service.BusName.__init__ is deprecated�)�
stacklevelz3requesting bus name %s returned unexpected value %s)r
�warnings�warn�DeprecationWarningr
Z
_bus_names�_dbus_bindingsZNAME_FLAG_ALLOW_REPLACEMENTZNAME_FLAG_REPLACE_EXISTINGZNAME_FLAG_DO_NOT_QUEUEZrequest_nameZ REQUEST_NAME_REPLY_PRIMARY_OWNERZREQUEST_NAME_REPLY_IN_QUEUEZREQUEST_NAME_REPLY_EXISTSrZ REQUEST_NAME_REPLY_ALREADY_OWNER�RuntimeError�object�__new__�_bus�_name)
�cls�nameZbusZallow_replacementZreplace_existingZdo_not_queuer%Z
name_flags�retval�bus_namerrrr+Ts2









zBusName.__new__cOsdS)Nr)r�args�keywordsrrr�__init__�szBusName.__init__cCs|jj|j�dS)N)r,Zrelease_namer-)rrrr�__del__�szBusName.__del__cCs|jS)zGet the Bus this Service is on)r,)rrrr�get_bus�szBusName.get_buscCs|jS)zGet the name of this service)r-)rrrr�get_name�szBusName.get_namecCsd|j|jt|�fS)Nz&<dbus.service.BusName %s on %r at %#x>)r-r,�id)rrrr�__repr__�szBusName.__repr__)NFFF)rrr r!r+r4r5r6r7r9�__str__rrrrrDs
OcCs^d}d}d}|r�x�|jjD]�}|rz||jkrzd|j|jkrvd|j|jkrv|j|j|krz|}|j|}d}Pqzn|}|r||jkrd|j|jkrd|j|jkr|j|j|kr|j|}d}PqWnTxR|jjD]F}|r�||jkr�|}|r�||jkr�d|j|jkr�|j|}d}Pq�W|�r6|j||fS|�rNtd||f��ntd|��dS)z�Walks the Python MRO of the given class to find the method to invoke.

    Returns two methods, the one to call, and the one it inherits from which
    defines its D-Bus interface name, signature, and attributes.
    NF�_dbus_is_method�_dbus_interfaceTz(%s is not a valid method of interface %sz%s is not a valid method)�	__class__�__mro__�__dict__r<r)r�method_nameZdbus_interface�
parent_methodZcandidate_classZ
successfulr.rrr�_method_lookup�sF


rBc Gs�t|�}y|j|d|i�Wn�tk
r�}zvtj�|dkr�y|j|�d}Wn6tk
r�}ztjd||j|��WYdd}~XnXtjd|||j|��WYdd}~XnX|j	|�dS)N�	signaturez
 (guessed)z2Unable to guess signature for arguments %r: %s: %sz8Unable to append %r to message with signature %s: %s: %s)
r�append�	Exception�loggingZbasicConfigZguess_signature�_logger�errorr=�send_message)�
connection�messager@rCr0�reply�errr�_method_reply_return�s rNc	Cs�t|dd�}|dk	rn0t|dd�dkr4d|jj}nd|j|jjf}tj�\}}}t|t�rp|jrp|j	�}n2||kr�dj
tj|||��}ndj
tj
|j|��}t|||�}|j|�dS)NZ_dbus_error_namer��__main__zorg.freedesktop.DBus.Python.%sz!org.freedesktop.DBus.Python.%s.%s)rOrP)�getattrr=rr�sys�exc_info�
isinstancerZinclude_tracebackZget_dbus_message�join�	traceback�format_exception�format_exception_onlyrrI)	rJrK�	exceptionr/ZetZevZetb�contentsrLrrr�_method_reply_errors
r[cs,eZdZ�fdd�Zdd�Zdd�Z�ZS)�
InterfaceTypecs�t|di�}||_i}||jd|<xX|D]P}|jd|j}t|dd�r.x.||j�D]\}}	|j|i�}
|
j|	�q\Wq.Wx4|j�D](}t|dd�r�|j|ji�}	||	|j<q�Wt	t
|�j|||�dS)N�_dbus_class_table�.Fr<)rQr]rr�items�
setdefault�update�valuesr<�superr\r4)r.r/�basesZdctZclass_tableZinterface_table�bZ	base_nameZ	interfaceZmethod_tableZour_method_table�func)r=rrr4,s
zInterfaceType.__init__cCs�|j}|jrtt|j��}nt�}|jr4t|j�}ng}d|j}xt||�D]}|d|7}qNWx|D]}|d|7}qhW|d7}|S)Nz    <method name="%s">
z2      <arg direction="in"  type="%s" name="%s" />
z(      <arg direction="out" type="%s" />
z    </method>
)�
_dbus_argsZ_dbus_in_signature�tuplerr�_dbus_out_signaturer�zip)r.rfr2Zin_sigZout_sig�reflection_data�pair�typerrr�_reflect_on_methodFs

z InterfaceType._reflect_on_methodcCsX|j}|jrtt|j��}nt�}d|j}xt||�D]}|d|}q8W|d}|S)Nz    <signal name="%s">
z"      <arg type="%s" name="%s" />
z    </signal>
)rgZ_dbus_signaturerhrrrrj)r.rfr2Zsigrkrlrrr�_reflect_on_signalcs
z InterfaceType._reflect_on_signal)rrr r4rnro�
__classcell__rr)r=rr\+sr\�	Interfacec@s�eZdZdZdZdZddd�Zedd��Zedd	��Z	ed
d��Z
dd
�Zddd�Zdd�Z
dd�Zeeddddd�dd��Zdd�ZeZdS)ra�A base class for exporting your own Objects across the Bus.

    Just inherit from Object and mark exported methods with the
    @\ `dbus.service.method` or @\ `dbus.service.signal` decorator.

    Example::

        class Example(dbus.service.object):
            def __init__(self, object_path):
                dbus.service.Object.__init__(self, dbus.SessionBus(), path)
                self._last_input = None

            @dbus.service.method(interface='com.example.Sample',
                                 in_signature='v', out_signature='s')
            def StringifyVariant(self, var):
                self.LastInputChanged(var)      # emits the signal
                return str(var)

            @dbus.service.signal(interface='com.example.Sample',
                                 signature='v')
            def LastInputChanged(self, var):
                # run just before the signal is actually emitted
                # just put "pass" if nothing should happen
                self._last_input = var

            @dbus.service.method(interface='com.example.Sample',
                                 in_signature='', out_signature='v')
            def GetLastInput(self):
                return self._last_input
    FNcCs�|dk	rt|�t|t�r(|}|j�}n|dkr@|dk	r@|j�}d|_d|_g|_tj�|_	d|_
||_|dkr�|dk	r�td��|dk	r�|dk	r�|j
||�dS)aConstructor. Either conn or bus_name is required; object_path
        is also required.

        :Parameters:
            `conn` : dbus.connection.Connection or None
                The connection on which to export this object.

                If None, use the Bus associated with the given ``bus_name``.
                If there is no ``bus_name`` either, the object is not
                initially available on any Connection.

                For backwards compatibility, if an instance of
                dbus.service.BusName is passed as the first parameter,
                this is equivalent to passing its associated Bus as
                ``conn``, and passing the BusName itself as ``bus_name``.

            `object_path` : str or None
                A D-Bus object path at which to make this Object available
                immediately. If this is not None, a `conn` or `bus_name` must
                also be provided.

            `bus_name` : dbus.service.BusName or None
                Represents a well-known name claimed by this process. A
                reference to the BusName object will be held by this
                Object, preventing the name from being released during this
                Object's lifetime (unless it's released manually).
        NFz<If object_path is given, either conn or bus_name is required)rrTrr6�_object_path�_connection�
_locations�	threadingZLock�_locations_lock�	_fallbackr-�	TypeError�add_to_connection)r�conn�object_pathr1rrrr4�s$


zObject.__init__cCs:|jtkrtd|��n|jdkr0td|��n|jSdS)z�The object-path at which this object is available.
        Access raises AttributeError if there is no object path, or more than
        one object path.

        Changed in 0.82.0: AttributeError can be raised.
        zEObject %r has more than one object path: use Object.locations insteadNz Object %r has no object path yet)rr�_MANY�AttributeError)rrrr�__dbus_object_path__�s


zObject.__dbus_object_path__cCs:|jtkrtd|��n|jdkr0td|��n|jSdS)z�The Connection on which this object is available.
        Access raises AttributeError if there is no Connection, or more than
        one Connection.

        Changed in 0.82.0: AttributeError can be raised.
        zFObject %r is on more than one Connection: use Object.locations insteadNzObject %r has no Connection yet)rsr|r})rrrrrJ�s


zObject.connectioncCs
t|j�S)aeAn iterable over tuples representing locations at which this
        object is available.

        Each tuple has at least two items, but may have more in future
        versions of dbus-python, so do not rely on their exact length.
        The first two items are the dbus.connection.Connection and the object
        path.

        :Since: 0.82.0
        )�iterrt)rrrr�	locationsszObject.locationscCs�|tkrtdt��|jj�z�|jdk	rN|j|k	rN|jrNtd||jf��|jdk	r||jr||j|kr|td||jf��|j||j	|j
|j�|jdkr�||_n|j|k	r�t|_|jdkr�||_n|j|kr�t|_|j
j|||jf�Wd|jj�XdS)aNMake this object accessible via the given D-Bus connection and
        object path.

        :Parameters:
            `connection` : dbus.connection.Connection
                Export the object on this connection. If the class attribute
                SUPPORTS_MULTIPLE_CONNECTIONS is False (default), this object
                can only be made available on one connection; if the class
                attribute is set True by a subclass, the object can be made
                available on more than one connection.

            `path` : dbus.ObjectPath or other str
                Place the object at this object path. If the class attribute
                SUPPORTS_MULTIPLE_OBJECT_PATHS is False (default), this object
                can only be made available at one object path; if the class
                attribute is set True by a subclass, the object can be made
                available with more than one object path.

        :Raises ValueError: if the object's class attributes do not allow the
            object to be exported in the desired way.
        :Since: 0.82.0
        z3Objects may not be exported on the reserved path %sNz'%r is already exported on connection %rz(%r is already exported at object path %s)r�
ValueErrorrv�acquirers�SUPPORTS_MULTIPLE_CONNECTIONSrr�SUPPORTS_MULTIPLE_OBJECT_PATHSZ_register_object_path�_message_cb�_unregister_cbrwr|rtrD�release)rrJ�pathrrrrys8









zObject.add_to_connectioncCs$|jj��z|jdks"|jdkr.td|��|dk	s>|dk	r�g}xN|jD]6}|dksb|d|krJ|dksv|d|krJ|j|�qJWn|j}g|_|s�td|||f��xf|D]^}y|dj|d�Wntk
r�YnX|jr�y|jj|�Wq�t	k
�r
Yq�Xq�WWd|jj
�XdS)aMake this object inaccessible via the given D-Bus connection
        and object path. If no connection or path is specified,
        the object ceases to be accessible via any connection or path.

        :Parameters:
            `connection` : dbus.connection.Connection or None
                Only remove the object from this Connection. If None,
                remove from all Connections on which it's exported.
            `path` : dbus.ObjectPath or other str, or None
                Only remove the object from this object path. If None,
                remove from all object paths.
        :Raises LookupError:
            if the object was not exported on the requested connection
            or path, or (if both are None) was not exported at all.
        :Since: 0.81.1
        Nz%r is not exportedr�z1%r is not exported at a location matching (%r,%r))rvr�rrrs�LookupErrorrtrDZ_unregister_object_path�remover�r�)rrJr�Zdropped�locationrrr�remove_from_connectionPs4

zObject.remove_from_connectioncCstjd||�dS)Nz5Unregistering exported object %r from some path on %r)rG�info)rrJrrrr��szObject._unregister_cbcs�t�t�sdS�y`�j���j�}t|�|�\}}�jf|j�}i}|jdk	rZt|j��nd�|j	r�|j	\}}	����fdd�||<��fdd�||	<|j
r��j�||j
<|jr��j
�||j<|j�r^�j
�}
|
}xx|jD]n}|d�kr�|
|dk�r�d}P|ddk�rq�|
j|dd�r�|
t|d�d�}
t|
�t|�kr�|
}q�Wt|�}|||j<|j�rt�j�||j<|j�r��||j<|j�r��||j<||f|�|�}|j	�r�dS�dk	�r(t��}t|�dk�r�|dk�r�f}ntd���n4t|�dk�r|f}nt|t��rntd��f��n2|dk�r8f}n"t|t��rTt|t��rTn|f}t����f|��Wn0tk
�r�}zt��|�WYdd}~XnXdS)	Ncst����f|��S)N)rN)r0)rJrKr@rCrr�<lambda>�sz$Object._message_cb.<locals>.<lambda>cst��|�S)N)r[)rY)rJrKrrr��srr��/z8%s has an empty output signature but did not return NonezK%s has multiple output values in signature %s but did not return a sequence)rTrZ
get_memberZ
get_interfacerBZ
get_args_listZ_dbus_get_args_optionsrirZ_dbus_async_callbacksZ_dbus_sender_keywordZ
get_senderZ_dbus_path_keyword�get_pathZ_dbus_rel_path_keywordrt�
startswith�lenr	Z_dbus_destination_keywordZget_destinationZ_dbus_message_keywordZ_dbus_connection_keywordrhrxrrrNrEr[)rrJrKZinterface_nameZcandidate_methodrAr2r3Zreturn_callbackZerror_callbackr�Zrel_pathZexp�suffixr0Zsignature_tuplerYr)rJrKr@rCrr��s�









zObject._message_cbrO�sr{rJ)Zin_signatureZ
out_signatureZpath_keywordZconnection_keywordcCs�tj}|d|7}|j|jjd|jj}xt|j�D]h\}}|d|7}xJ|j�D]>}t|dd�rv||jj	|�7}qTt|dd�rT||jj
|�7}qTW|d7}q6Wx|j|�D]}|d|7}q�W|d	7}|S)
ziReturn a string of XML encoding this object's supported interfaces,
        methods and signals.
        z<node name="%s">
r^z  <interface name="%s">
r;FZ_dbus_is_signalz  </interface>
z  <node name="%s"/>
z</node>
)r(Z)DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODEr]r=rrr_rbrQrnroZlist_exported_child_objects)rr{rJrkZ
interfacesr/Zfuncsrfrrr�
Introspect�szObject.IntrospectcCs>d}|jtk	r"|jdk	r"d|j}d|jj|jj|t|�fS)NrOz at %sz<%s.%s%s at %#x>)rrr|r=rrr8)r�whererrrr9s


zObject.__repr__)NNN)NN)rrr r!r�r�r4�propertyr~rJr�ryr�r�r�rrr�r9r:rrrrrs
=;
1ncs&eZdZdZdZd�fdd�	Z�ZS)rzaAn object that implements an entire subtree of the object-path
    tree.

    :Since: 0.82.0
    TNcsPtt|�j�d|_|dkr.|dk	rLtd��n|dkr@td��n|j||�dS)aHConstructor.

        Note that the superclass' ``bus_name`` __init__ argument is not
        supported here.

        :Parameters:
            `conn` : dbus.connection.Connection or None
                The connection on which to export this object. If this is not
                None, an `object_path` must also be provided.

                If None, the object is not initially available on any
                Connection.

            `object_path` : str or None
                A D-Bus object path at which to make this Object available
                immediately. If this is not None, a `conn` must also be
                provided.

                This object will implements all object-paths in the subtree
                starting at this object-path, except where a more specific
                object has been added.
        TNz)If object_path is given, conn is requiredz)If conn is given, object_path is required)rcrr4rwrxry)rrzr{)r=rrr4#s

zFallbackObject.__init__)NN)rrr r!r�r4rprr)r=rrs)rrrrr).�__all__Z
__docformat__rRrFrurV�collectionsrr(Zdbusrr	r
rrr
rZdbus.decoratorsrrZdbus.exceptionsrrrZ
dbus.lowlevelrrrZdbus.proxiesrZdbus._compatrZ	getLoggerrGr*rrrBrNr[rmr\rqr|rrrrrr�<module>s6$
uBM