Mini Shell

Direktori : /usr/lib/python3.6/site-packages/dasbus/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dasbus/__pycache__/connection.cpython-36.pyc

3

��^�'�@s�ddlZddlZddlmZmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlZejdd�dd	lmZeje�Zd
ddd
dgZGdd
�d
e�ZGdd�ded�ZGdd�de�ZGdd�de�ZGdd
�d
e�ZGdd�de�ZdS)�N)�ABCMeta�abstractmethod)� DBUS_NAME_FLAG_ALLOW_REPLACEMENT�%DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)�ObjectProxy)�ErrorMapper)�ServerObjectHandler�Gioz2.0)r	�GLibConnection�
MessageBus�SystemMessageBus�SessionMessageBus�AddressedMessageBusc@sPeZdZdZejjejjBZe	d	dd��Z
e	d
dd��Ze	eddfdd��ZdS)r
z4The low-level DBus connection library based on GLib.NcCstjd�tjtjj|�S)zGet a system bus connection.zConnecting to the system bus.)�log�infor	�bus_get_sync�BusTypeZSYSTEM)�cancellable�r� /usr/lib/python3.6/connection.py�get_system_bus_connection6s
z(GLibConnection.get_system_bus_connectioncCstjd�tjtjj|�S)zGet a session bus connection.zConnecting to the session bus.)rrr	rrZSESSION)rrrr�get_session_bus_connection?s
z)GLibConnection.get_session_bus_connectioncCstjj||||�S)z3Get a connection to a bus at the specified address.)r	ZDBusConnectionZnew_for_address_sync)Zbus_address�flagsZobserverrrrr�get_addressed_bus_connectionHs
z+GLibConnection.get_addressed_bus_connection)N)N)
�__name__�
__module__�__qualname__�__doc__r	ZDBusConnectionFlagsZAUTHENTICATION_CLIENTZMESSAGE_BUS_CONNECTIONZ
DEFAULT_FLAGS�staticmethodrrrrrrrr
.s
c@sXeZdZdZeedd���Zdd�Zedd��Zedd	��Z	ed
d��Z
edd
��ZdS)�AbstractMessageBusa
Abstract representation of a message bus.

    The property connection represents a connection to the bus. You can
    register a service name with register_service, or publish an object
    with publish_object and get a proxy of a remote object with get_proxy.
    cCsdS)zThe DBus connection.Nr)�selfrrr�
connection\szAbstractMessageBus.connectioncCs<y
|jdk	Stk
r6}ztjd|�dSd}~XnXdS)znCheck if the connection is set up.

        :return: True if the connection is set up otherwise False
        NzConnection can't be created:
%sF)r!�	ExceptionrZwarning)r �errr�check_connectionbs

z#AbstractMessageBus.check_connectioncKsdS)z�Returns a proxy of a remote DBus object.

        :param service_name: a DBus name of a service
        :param object_path: a DBus path an object
        :return: a proxy object
        Nr)r �service_name�object_path�kwargsrrr�	get_proxymszAbstractMessageBus.get_proxycKsdS)aRegister a service on DBus.

        A service can be registered by requesting its name on DBus.
        This method should be called only after all of the required
        objects of the service are published on DBus.

        :param service_name: a DBus name of a service
        Nr)r r%r'rrr�register_servicews
z#AbstractMessageBus.register_servicecKsdS)z�Publish an object on DBus.

        :param object_path: a DBus path of an object
        :param obj: an instance of @dbus_interface or @dbus_class
        Nr)r r&�objr'rrr�publish_object�sz!AbstractMessageBus.publish_objectcCsdS)zDisconnect from DBus.Nr)r rrr�
disconnect�szAbstractMessageBus.disconnectN)rrrr�propertyrr!r$r(r)r+r,rrrrrTs
	r)�	metaclasscs~eZdZdZdef�fdd�	Zedd��Zedd��Z	ed	d
��Z
efdd�Zd
d�Z
efdd�Zefdd�Zdd�Z�ZS)rz/Representation of a message bus based on D-Bus.Ncs:t�j�||_|pt�|_d|_d|_g|_t�|_	dS)z�Create a new message bus.

        :param error_mapper: a DBus error mapper
        :param provider: a provider of DBus connections
        N)
�super�__init__�	_providerr�
_error_mapper�_connection�_proxy�_registrations�set�_requested_names)r �error_mapperZprovider)�	__class__rrr0�s
zMessageBus.__init__cCs|js|j�|_|jS)zThe DBus connection.)r3�_get_connection)r rrrr!�s
zMessageBus.connectioncCsdS)zReturn a DBus connection.Nr)r rrrr:�szMessageBus._get_connectioncCs|js|jdd�|_|jS)zThe proxy of DBus.zorg.freedesktop.DBusz/org/freedesktop/DBus)r4r()r rrr�proxy�s
zMessageBus.proxycKs$|j|�||||fd|ji|��S)aDReturns a proxy of a remote DBus object.

        :param service_name: a DBus name of a service
        :param object_path: a DBus path an object
        :param proxy_factory: a factory of a DBus object proxy
        :param proxy_arguments: additional arguments for the proxy factory
        :return: a proxy object
        r8)�_check_service_accessr2)r r%r&Z
proxy_factoryZproxy_argumentsrrrr(�s

zMessageBus.get_proxycCs4||jkrdStj�tj�k	r"dStdj|���dS)a�Check if we can access a DBus service.

        FIXME: This is a temporary check that should be later removed.

        This is useful during the transition of the Anaconda code from
        UI to DBus modules. This check prevents a deadlock in case that
        a DBus module tries to access a service, that it provides, from
        the main thread.

        :param service_name: a DBus name of a service
        :raises: RuntimeError if the service cannot be accessed
        Nz4Can't access DBus service '{}' from the main thread.)r7�	threadingZcurrent_threadZmain_thread�RuntimeError�format)r r%rrrr<�s
z MessageBus._check_service_accesscsVtjd���jj�|�}|tkr0tdj|����jj���j	j
��fdd��dS)z�Register a service on DBus.

        :param service_name: a DBus name of a service
        :param flags: the flags argument of the RequestName DBus method
        zRegistering a service name %s.zName request has failed: {}cs�jj��S)N)r;ZReleaseNamer)r r%rr�<lambda>�sz-MessageBus.register_service.<locals>.<lambda>N)r�debugr;ZRequestNamer�ConnectionErrorr?r7�addr5�append)r r%r�resultr)r r%rr)�szMessageBus.register_servicecCs8tjd|�|||||jd�}|j�|jj|j�dS)z�Publish an object on DBus.

        :param object_path: a DBus path of an object
        :param obj: an instance of @dbus_interface or @dbus_class
        :param server_factory: a factory of a DBus server object handler
        zPublishing an object at %s.)r8N)rrAr2Zconnect_objectr5rDZdisconnect_object)r r&r*Zserver_factoryZobject_handlerrrrr+�s
zMessageBus.publish_objectcCs8tjd�x|jr$|jj�}|�qWd|_t�|_dS)zDisconnect from DBus.zDisconnecting from the bus.N)rrAr5�popr3r6r7)r �callbackrrrr,s


zMessageBus.disconnect)rrrrr
r0r-r!rr:r;rr(r<rr)rr+r,�
__classcell__rr)r9rr�sc@seZdZdZdd�ZdS)rz*Representation of a system bus connection.cCstjd�|jj�S)zGet a system DBus connection.zConnecting to the system bus.)rrr1r)r rrrr:!s
z SystemMessageBus._get_connectionN)rrrrr:rrrrrsc@seZdZdZdd�ZdS)r
z+Representation of a session bus connection.cCstjd�|jj�S)zGet a session DBus connection.zConnecting to the session bus.)rrr1r)r rrrr:*s
z!SessionMessageBus._get_connectionN)rrrrr:rrrrr
'scs4eZdZdZ�fdd�Zedd��Zdd�Z�ZS)rz9Representation of a connection for the specified address.cst�j||�||_dS)z\Create a new representation of a connection.

        :param address: a bus address
        N)r/r0�_address)r �address�argsr')r9rrr03szAddressedMessageBus.__init__cCs|jS)zThe bus address.)rI)r rrrrJ;szAddressedMessageBus.addresscCstjd|j�|jj|j�S)z3Get a connection to a bus at the specified address.zConnecting to a bus at %s.)rrrIr1r)r rrrr:@sz#AddressedMessageBus._get_connection)	rrrrr0r-rJr:rHrr)r9rr0s)Zloggingr=�abcrrZdasbus.constantsrrZdasbus.client.proxyrZdasbus.errorrZdasbus.server.handlerrZgiZrequire_versionZ
gi.repositoryr	Z	getLoggerrr�__all__�objectr
rrrr
rrrrr�<module>s,
&>