HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/dasbus/__pycache__/connection.cpython-39.pyc
a

װ_�*�@s�ddlZddlZddlmZmZddlmZmZddlm	Z	m
Z
ddlmZddl
mZddlZe�dd�dd	lmZe�e�Zgd
�ZGdd�de�ZGd
d�ded�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�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@sPeZdZdZejjejjBZe	d	dd��Z
e	d
dd��Ze	eddfdd��ZdS)rz4The low-level DBus connection library based on GLib.NcCst�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_connection6s

�z(GLibConnection.get_system_bus_connectioncCst�d�t�tjj|�S)zGet a session bus connection.�Connecting to the session bus.)rrr
rrZSESSIONrrrr�get_session_bus_connection?s

�z)GLibConnection.get_session_bus_connectioncCstj�||||�S)�3Get 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���rc@sZeZdZdZeedd���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.
    cCsdS)�The DBus connection.Nr��selfrrr�
connection\szAbstractMessageBus.connectionc
CsDz|jduWSty>}zt�d|�WYd}~dSd}~00dS)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_connectionNcKsdS)aReturns 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�kwargsrrr�	get_proxyms
zAbstractMessageBus.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_serviceys
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)�Disconnect from DBus.Nrr&rrr�
disconnect�szAbstractMessageBus.disconnect)N)rr r!r"�propertyrr(r+r0r1r3r5rrrrr$Ts

r$)�	metaclasscs|eZdZdZdef�fdd�	Zedd��Zedd��Z	ed	d
��Z
ddd�Zd
d�Ze
fdd�Zefdd�Zdd�Z�ZS)rz/Representation of a message bus based on D-Bus.Ncs: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__rrr9�s
zMessageBus.__init__cCs|js|��|_|jS)r%)r<�_get_connectionr&rrrr(�s
zMessageBus.connectioncCsdS)zReturn a DBus connection.Nrr&rrrrD�szMessageBus._get_connectioncCs|js|�dd�|_|jS)zThe proxy of DBus.zorg.freedesktop.DBusz/org/freedesktop/DBus)r=r0r&rrr�proxy�s�zMessageBus.proxycKs@|�|�|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_accessrrr;)r'r,r-r.Z
proxy_factoryZproxy_argumentsrrrr0�s
���zMessageBus.get_proxycCs4||jvrdSt��t��ur"dStd�|���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,rrrrF�s
��z MessageBus._check_service_accesscsVt�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: {}cs�j���S)N)rEZReleaseNamerrLrr�<lambda>�z-MessageBus.register_service.<locals>.<lambda>N)r�debugrEZRequestNamer�ConnectionErrorrKr@�addr>�append)r'r,r�resultrrLrr1�s��zMessageBus.register_servicecCs8t�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.)rAN)rrOr;Zconnect_objectr>rRZdisconnect_object)r'r-r2Zserver_factoryZobject_handlerrrrr3s�zMessageBus.publish_objectcCs4t�d�|jr"|j��}|�q
d|_t�|_dS)r4zDisconnecting from the bus.N)rrOr>�popr<r?r@)r'�callbackrrrr5#s

zMessageBus.disconnect)NN)rr r!r"rr9r6r(rrDrEr0rFrr1r	r3r5�
__classcell__rrrBrr�s"


�
"�
�
rc@seZdZdZdd�ZdS)r
z*Representation of a system bus connection.cCst�d�|j��S)zGet a system DBus connection.r)rrr:rr&rrrrD2s
z SystemMessageBus._get_connectionN�rr r!r"rDrrrrr
/sr
c@seZdZdZdd�ZdS)rz+Representation of a session bus connection.cCst�d�|j��S)zGet a session DBus connection.r)rrr:rr&rrrrD;s
z!SessionMessageBus._get_connectionNrWrrrrr8srcs4eZdZdZ�fdd�Zedd��Zdd�Z�ZS)rz9Representation of a connection for the specified address.cst�j|i|��||_dS)z\Create a new representation of a connection.

        :param address: a bus address
        N)r8r9�_address)r'�address�argsr/rBrrr9DszAddressedMessageBus.__init__cCs|jS)zThe bus address.)rXr&rrrrYLszAddressedMessageBus.addresscCst�d|j�|j�|j�S)rzConnecting to a bus at %s.)rrrXr:rr&rrrrDQsz#AddressedMessageBus._get_connection)	rr r!r"r9r6rYrDrVrrrBrrAs

r)ZloggingrG�abcrrZdasbus.constantsrrZdasbus.client.proxyrrZdasbus.errorrZdasbus.server.handlerr	ZgiZrequire_versionZ
gi.repositoryr
Z	getLoggerrr�__all__�objectrr$rr
rrrrrr�<module>s$
	&@