관리-도구
편집 파일: connection.cpython-39.pyc
a ����װ_�*����������������������@���s����d�dl�Z�d�dlZd�dlmZmZ�d�dlmZmZ�d�dlm Z m Z �d�dlmZ�d�dl mZ�d�dlZe�dd��d�d lmZ�e��e�Zg�d �ZG�dd��de�ZG�d d��ded�ZG�dd��de�ZG�dd��de�ZG�dd��de�ZG�dd��de�ZdS�)�����N)�ABCMeta�abstractmethod)� DBUS_NAME_FLAG_ALLOW_REPLACEMENT�%DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)�ObjectProxy�InterfaceProxy)�ErrorMapper)�ServerObjectHandler�Gioz2.0)r ���)�GLibConnection� MessageBus�SystemMessageBus�SessionMessageBus�AddressedMessageBusc�������������������@���sP���e�Zd�ZdZejjejjB�Ze d dd��Z e d dd��Ze eddfdd��ZdS�)r���z4The low-level DBus connection library based on GLib.Nc�����������������C���s���t��d��t�tjj|��S�)zGet a system bus connection.�Connecting to the system bus.)�log�infor ����bus_get_sync�BusTypeZSYSTEM��cancellable��r����5/usr/lib/python3.9/site-packages/dasbus/connection.py�get_system_bus_connection6���s ���� �z(GLibConnection.get_system_bus_connectionc�����������������C���s���t��d��t�tjj|��S�)zGet a session bus connection.�Connecting to the session bus.)r���r���r ���r���r���ZSESSIONr���r���r���r����get_session_bus_connection?���s ���� �z)GLibConnection.get_session_bus_connectionc�����������������C���s���t�j�|�|||�S�)�3Get a connection to a bus at the specified address.)r ���ZDBusConnectionZnew_for_address_sync)Zbus_address�flagsZobserverr���r���r���r����get_addressed_bus_connectionH���s�����z+GLibConnection.get_addressed_bus_connection)N)N) �__name__� __module__�__qualname__�__doc__r ���ZDBusConnectionFlagsZAUTHENTICATION_CLIENTZMESSAGE_BUS_CONNECTIONZ DEFAULT_FLAGS�staticmethodr���r���r���r���r���r���r���r���.���s������r���c�������������������@���sZ���e�Zd�ZdZeedd����Zdd��Zeddd��Zed d ���Z edd���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. c�����������������C���s���dS�)�The DBus connection.Nr�����selfr���r���r���� connection\���s����zAbstractMessageBus.connectionc�������������� ���C���sD���z|�j�duW�S��ty>�}�zt�d|��W�Y�d}~dS�d}~0�0�dS�)znCheck if the connection is set up. :return: True if the connection is set up otherwise False NzConnection can't be created: %sF)r(���� Exceptionr���Zwarning)r'����er���r���r����check_connectionb���s ����z#AbstractMessageBus.check_connectionNc�����������������K���s���dS�)a���Returns a proxy of a remote DBus object. :param service_name: a DBus name of a service :param object_path: a DBus path of an object :param interface_name: a DBus name of an interface or None :return: a proxy object Nr���)r'����service_name�object_path�interface_name�kwargsr���r���r���� get_proxym���s���� zAbstractMessageBus.get_proxyc�����������������K���s���dS�)a��Register 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/���r���r���r����register_servicey���s���� z#AbstractMessageBus.register_servicec�����������������K���s���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 Nr���)r'���r-����objr/���r���r���r����publish_object����s����z!AbstractMessageBus.publish_objectc�����������������C���s���dS�)�Disconnect from DBus.Nr���r&���r���r���r���� disconnect����s����zAbstractMessageBus.disconnect)N)r���r ���r!���r"����propertyr���r(���r+���r0���r1���r3���r5���r���r���r���r���r$���T���s��� r$���)� metaclassc�����������������������s|���e�Zd�ZdZdef��fdd� Zedd���Zedd���Z ed d ���Z ddd�Zd d��Ze fdd�Zefdd�Zdd��Z���ZS�)r���z/Representation of a message bus based on D-Bus.Nc��������������������s:���t�������||�_|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__r���r���r9�������s���� zMessageBus.__init__c�����������������C���s���|�j�s|����|�_�|�j�S�)r%���)r<����_get_connectionr&���r���r���r���r(�������s���� zMessageBus.connectionc�����������������C���s���dS�)zReturn a DBus connection.Nr���r&���r���r���r���rD�������s����zMessageBus._get_connectionc�����������������C���s���|�j�s|��dd�|�_�|�j�S�)zThe proxy of DBus.zorg.freedesktop.DBusz/org/freedesktop/DBus)r=���r0���r&���r���r���r����proxy����s�����zMessageBus.proxyc�����������������K���s@���|���|��|s|rtnt}|r&||d<�||�||fd|�ji|��S�)a���Returns a proxy of a remote DBus object. If the proxy factory is not specified, we will use a default one. If the interface name is set, we will choose InterfaceProxy, otherwise ObjectProxy. If the interface name is set, we will add it to the additional arguments for the proxy factory. :param service_name: a DBus name of a service :param object_path: a DBus path of an object :param interface_name: a DBus name of an interface or None :param proxy_factory: a factory of a DBus object proxy :param proxy_arguments: additional arguments for the proxy factory :return: a proxy object r.���rA���)�_check_service_accessr���r���r;���)r'���r,���r-���r.���Z proxy_factoryZproxy_argumentsr���r���r���r0�������s���� ���zMessageBus.get_proxyc�����������������C���s4���||�j�vrdS�t���t���ur"dS�td�|���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.)r@���� threading�current_thread�main_thread�RuntimeError�format�r'���r,���r���r���r���rF�������s���� ��z MessageBus._check_service_accessc��������������������sV���t��d�����j��|�}|tkr0td�|�����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: {}c����������������������s�����j����S�)N)rE���ZReleaseNamer���rL���r���r����<lambda>�������z-MessageBus.register_service.<locals>.<lambda>N)r����debugrE���ZRequestNamer����ConnectionErrorrK���r@����addr>����append)r'���r,���r����resultr���rL���r���r1�������s������zMessageBus.register_servicec�����������������C���s8���t��d|��||�|||�jd�}|����|�j�|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.)rA���N)r���rO���r;���Zconnect_objectr>���rR���Zdisconnect_object)r'���r-���r2���Zserver_factoryZobject_handlerr���r���r���r3�����s�����zMessageBus.publish_objectc�����������������C���s4���t��d��|�jr"|�j���}|���q d|�_t��|�_dS�)r4���zDisconnecting from the bus.N)r���rO���r>����popr<���r?���r@���)r'����callbackr���r���r���r5���#��s���� zMessageBus.disconnect)NN)r���r ���r!���r"���r���r9���r6���r(���r���rD���rE���r0���rF���r���r1���r ���r3���r5���� __classcell__r���r���rB���r���r�������s"��� ��� "� � r���c�������������������@���s���e�Zd�ZdZdd��ZdS�)r ���z*Representation of a system bus connection.c�����������������C���s���t��d��|�j���S�)zGet a system DBus connection.r���)r���r���r:���r���r&���r���r���r���rD���2��s���� z SystemMessageBus._get_connectionN�r���r ���r!���r"���rD���r���r���r���r���r ���/��s���r ���c�������������������@���s���e�Zd�ZdZdd��ZdS�)r���z+Representation of a session bus connection.c�����������������C���s���t��d��|�j���S�)zGet a session DBus connection.r���)r���r���r:���r���r&���r���r���r���rD���;��s���� z!SessionMessageBus._get_connectionNrW���r���r���r���r���r���8��s���r���c�����������������������s4���e�Zd�ZdZ��fdd�Zedd���Zdd��Z���ZS�)r���z9Representation of a connection for the specified address.c��������������������s���t���j|i�|���||�_dS�)z\Create a new representation of a connection. :param address: a bus address N)r8���r9����_address)r'����address�argsr/���rB���r���r���r9���D��s����zAddressedMessageBus.__init__c�����������������C���s���|�j�S�)zThe bus address.)rX���r&���r���r���r���rY���L��s����zAddressedMessageBus.addressc�����������������C���s���t��d|�j��|�j�|�j�S�)r���zConnecting to a bus at %s.)r���r���rX���r:���r���r&���r���r���r���rD���Q��s����z#AddressedMessageBus._get_connection) r���r ���r!���r"���r9���r6���rY���rD���rV���r���r���rB���r���r���A��s ��� r���)ZloggingrG����abcr���r���Zdasbus.constantsr���r���Zdasbus.client.proxyr���r���Zdasbus.errorr���Zdasbus.server.handlerr ���ZgiZrequire_versionZ gi.repositoryr ���Z getLoggerr���r����__all__�objectr���r$���r���r ���r���r���r���r���r���r����<module>���s$��� &@�