Your IP : 3.145.43.200


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

3

iR�VF�@s�dZdZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZddlmZddlmZddl m!Z!ddl"m#Z#d	eeefZ$d
Z%ej&d�Z'Gdd
�d
e(�Z)Gdd�de�Z*dS)�
BusConnectionZreStructuredText�N)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�BUS_SESSION�BUS_STARTER�
BUS_SYSTEM� DBUS_START_REPLY_ALREADY_RUNNING�DBUS_START_REPLY_SUCCESS�NAME_FLAG_ALLOW_REPLACEMENT�NAME_FLAG_DO_NOT_QUEUE�NAME_FLAG_REPLACE_EXISTING�RELEASE_NAME_REPLY_NON_EXISTENT�RELEASE_NAME_REPLY_NOT_OWNER�RELEASE_NAME_REPLY_RELEASED� REQUEST_NAME_REPLY_ALREADY_OWNER�REQUEST_NAME_REPLY_EXISTS�REQUEST_NAME_REPLY_IN_QUEUE� REQUEST_NAME_REPLY_PRIMARY_OWNER�validate_bus_name�validate_error_name�validate_interface_name�validate_member_name�validate_object_path)�
Connection)�
DBusException)�HANDLER_RESULT_NOT_YET_HANDLED)�is_py2zWtype='signal',sender='%s',interface='%s',member='NameOwnerChanged',path='%s',arg0='%%s'z)org.freedesktop.DBus.Error.NameHasNoOwnerzdbus.busc@s eZdZdZdd�Zdd�ZdS)	�NameOwnerWatch�_match�
_pending_callc	snt���fdd�}��fdd�}|j|dttt�d�|_i}trJd|d<|jtttd	d
�f�|f|�|_dS)Ncs�|�dS)N�)ZownedZ	old_owner�	new_owner)�callbackr!�/usr/lib64/python3.6/bus.py�	signal_cb@sz*NameOwnerWatch.__init__.<locals>.signal_cbcs:|j�tkr�d�n tj�tjd�|j|dfd�dS)N�zGetNameOwner(%s) failed:)�exc_info)�
get_dbus_name�_NAME_HAS_NO_OWNER�loggingZbasicConfig�_logger�debug�	__class__)�e)�bus_namer#r!r$�error_cbCs

z)NameOwnerWatch.__init__.<locals>.error_cbZNameOwnerChanged)Zarg0T�utf8_strings�GetNameOwner�s)	r�add_signal_receiverrrrrr�
call_asyncr )�selfZbus_connr/r#r%r0�keywordsr!)r/r#r$�__init__=s&
zNameOwnerWatch.__init__cCs8|jdk	r|jj�|jdk	r(|jj�d|_d|_dS)N)r�remover �cancel)r6r!r!r$r:\s



zNameOwnerWatch.cancelN)rr )�__name__�
__module__�__qualname__�	__slots__r8r:r!r!r!r$r:srcs�eZdZdZeZeZeZ	e
ZeZ
edfdd�Zd*�fdd�	Zdd�Zd	d
�Zd+d
d�Zdd�Zd,dd�Zd-dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Z�Z S).rzxA connection to a D-Bus daemon that implements the
    ``org.freedesktop.DBus`` pseudo-service.

    :Since: 0.81.0
    NcCs"|j||d�}tj�|_i|_|S)N)�mainloop)Z_new_for_bus�weakref�WeakValueDictionaryZ
_bus_names�_signal_sender_matches)�clsZaddress_or_typer?Zbusr!r!r$�__new__ys
zBusConnection.__new__cs�|jdd�}|dk	rB|dk	r$td��|}ddlm}|dtdd�tt|�j|||||f|��|dk	r�|tkr�|dd�d	kr��fd
d�}	n�j	}	|j
||	�}
|
|j�<|jt
����S)N�
named_servicez3bus_name and named_service cannot both be specifiedr)�warnzrPassing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parameters�)�
stacklevel��:cs|dkr�j�dS)Nr&)r9)r")�matchr!r$r#�sz3BusConnection.add_signal_receiver.<locals>.callback)�pop�	TypeError�warningsrF�DeprecationWarning�superrr4rZset_sender_name_owner�watch_name_ownerrB�add_match_string�str)r6Zhandler_functionZsignal_nameZdbus_interfacer/�pathr7rErFr#�watch)r-)rKr$r4�s&



z!BusConnection.add_signal_receivercCs0|jt|��|jj|d�}|dk	r,|j�dS)N)� remove_match_string_non_blockingrSrBrLr:)r6rKrUr!r!r$�_clean_up_signal_match�sz$BusConnection._clean_up_signal_matchcCst|dk	rl|dd�dkrl|tkrly
|j|�Stk
rh}z"|j�tkrJ�|j|�|j|�Sd}~XqpXn|SdS)NrIrJ)r�get_name_ownerrr(r)�start_service_by_name)r6r/r.r!r!r$�activate_name_owner�s

z!BusConnection.activate_name_ownerTFcKs||r|j�|jdd�}|dk	rN|dk	r0td��ddlm}|dtdd�|}|rhtd	d
j|j����|j|||||d�S)aJReturn 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
            `follow_name_owner_changes` : bool
                If the object path is a well-known name and this parameter
                is false (default), resolve the well-known name to the unique
                name of its current owner and bind to that instead; if the
                ownership of the well-known name changes in future,
                keep communicating with the original owner.
                This is necessary if the D-Bus API used is stateful.

                If the object path is a well-known name and this parameter
                is true, whenever the well-known name changes ownership in
                future, bind to the new owner, if any.

                If the given object path is a unique name, this parameter
                has no effect.

        :Returns: a `dbus.proxies.ProxyObject`
        :Raises `DBusException`: if resolving the well-known name to a
            unique name fails
        rENz3bus_name and named_service cannot both be specifiedr)rFziPassing the named_service parameter to get_object by name is deprecated: please use positional parametersrG)rHz4get_object does not take these keyword arguments: %sz, )�
introspect�follow_name_owner_changes)	Z_require_main_looprLrMrNrFrO�join�keysZProxyObjectClass)r6r/Zobject_pathr[r\�kwargsrErFr!r!r$�
get_object�s $

zBusConnection.get_objectcCst|�|jtttdd|f�S)z�Get the numeric uid of the process owning the given bus name.

        :Parameters:
            `bus_name` : str
                A bus name, either unique or well-known
        :Returns: a `dbus.UInt32`
        :Since: 0.80.0
        ZGetConnectionUnixUserr3)r�
call_blockingrrr)r6r/r!r!r$�
get_unix_user�s	zBusConnection.get_unix_userrc	Cs$t|�d|jtttdd||f�fS)a?Start a service which will implement the given bus name on this Bus.

        :Parameters:
            `bus_name` : str
                The well-known bus name to be activated.
            `flags` : dbus.UInt32
                Flags to pass to StartServiceByName (currently none are
                defined)

        :Returns: A tuple of 2 elements. The first is always True, the
            second is either START_REPLY_SUCCESS or
            START_REPLY_ALREADY_RUNNING.

        :Raises `DBusException`: if the service could not be started.
        :Since: 0.80.0
        TZStartServiceByName�su)rrarrr)r6r/�flagsr!r!r$rYs

z#BusConnection.start_service_by_namecCs$t|dd�|jtttdd||f�S)a�Request a bus name.

        :Parameters:
            `name` : str
                The well-known name to be requested
            `flags` : dbus.UInt32
                A bitwise-OR of 0 or more of the flags
                `NAME_FLAG_ALLOW_REPLACEMENT`,
                `NAME_FLAG_REPLACE_EXISTING`
                and `NAME_FLAG_DO_NOT_QUEUE`
        :Returns: `REQUEST_NAME_REPLY_PRIMARY_OWNER`,
            `REQUEST_NAME_REPLY_IN_QUEUE`,
            `REQUEST_NAME_REPLY_EXISTS` or
            `REQUEST_NAME_REPLY_ALREADY_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        F)�allow_uniqueZRequestNamerc)rrarrr)r6�namerdr!r!r$�request_nameszBusConnection.request_namecCs"t|dd�|jtttdd|f�S)asRelease a bus name.

        :Parameters:
            `name` : str
                The well-known name to be released
        :Returns: `RELEASE_NAME_REPLY_RELEASED`,
            `RELEASE_NAME_REPLY_NON_EXISTENT`
            or `RELEASE_NAME_REPLY_NOT_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        F)reZReleaseNamer3)rrarrr)r6rfr!r!r$�release_name1szBusConnection.release_namecCs(i}trd|d<|jtttddff|�S)z�Return a list of all currently-owned names on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        Tr1Z	ListNamesr&)rrarrr)r6r7r!r!r$�
list_namesBszBusConnection.list_namescCs(i}trd|d<|jtttddff|�S)z�Return a list of all names that can be activated on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        Tr1ZListActivatableNamesr&)rrarrr)r6r7r!r!r$�list_activatable_namesOsz$BusConnection.list_activatable_namescCs6i}trd|d<t|dd�|jtttdd|ff|�S)z�Return the unique connection name of the primary owner of the
        given name.

        :Raises `DBusException`: if the `bus_name` has no owner
        :Since: 0.81.0
        Tr1F)rer2r3)rrrarrr)r6r/r7r!r!r$rX\szBusConnection.get_name_ownercCst|||�S)aWatch the unique connection name of the primary owner of the
        given name.

        `callback` will be called with one argument, which is either the
        unique connection name, or the empty string (meaning the name is
        not owned).

        :Since: 0.81.0
        )r)r6r/r#r!r!r$rQks
zBusConnection.watch_name_ownercCst|jtttdd|f��S)z�Return True iff the given bus name has an owner on this bus.

        :Parameters:
            `bus_name` : str
                The bus name to look up
        :Returns: a `bool`
        ZNameHasOwnerr3)�boolrarrr)r6r/r!r!r$�name_has_ownerws
zBusConnection.name_has_ownercCs|jtttdd|f�dS)aArrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        �AddMatchr3N)rarrr)r6�ruler!r!r$rR�s
zBusConnection.add_match_stringc	Cs|jtttdd|fdd�dS)a=Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        rmr3N)r5rrr)r6rnr!r!r$�add_match_string_non_blocking�s
z+BusConnection.add_match_string_non_blockingcCs|jtttdd|f�dS)aArrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        �RemoveMatchr3N)rarrr)r6rnr!r!r$�remove_match_string�s
z!BusConnection.remove_match_stringc	Cs|jtttdd|fdd�dS)a=Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        rpr3N)r5rrr)r6rnr!r!r$rV�s
z.BusConnection.remove_match_string_non_blocking)NNNN)TF)r)r)!r;r<r=�__doc__rZTYPE_SESSIONrZTYPE_SYSTEMrZTYPE_STARTERr
ZSTART_REPLY_SUCCESSr	ZSTART_REPLY_ALREADY_RUNNINGrDr4rWrZr`rbrYrgrhrirjrXrQrlrRrorqrV�
__classcell__r!r!)r-r$res6
8




)r)+�__all__Z
__docformat__r*r@Z_dbus_bindingsrrrrrrr	r
rrr
rrrrrrrrrrrrZdbus.connectionrZdbus.exceptionsrZ
dbus.lowlevelrZdbus._compatrZ_NAME_OWNER_CHANGE_MATCHr)Z	getLoggerr+�objectrrr!r!r!r$�<module>sd

+

?>