HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //proc/self/root/usr/lib/python3.9/site-packages/dasbus/client/__pycache__/observer.cpython-39.pyc
a

װ_[�@s�ddlZddlmZddlmZddlmZddlZe�dd�ddl	m
Z
e�e�Z
gd�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZdS)�N)�partial)�DBUS_FLAG_NONE)�Signal�Gioz2.0)r)�DBusObserverError�DBusObserver�GLibMonitoringc@seZdZdZdS)rz'Exception class for the DBus observers.N)�__name__�
__module__�__qualname__�__doc__�r
r
�:/usr/lib/python3.9/site-packages/dasbus/client/observer.pyr(src@sHeZdZdZeeddfdd��Zedd��Zedd��Zed	d
��Z	dS)rz4The low-level DBus monitoring library based on GLib.Nc	CsTd}d}|rt|j|dfd�}|r4t|j|dfd�}t�|||||�}t|j||�S)z,Watch a service name on the DBus connection.Nr
)�	user_data)r�_name_appeared_callback�_name_vanished_callbackrZbus_watch_name_on_connection�
_unwatch_name)	�cls�
connection�name�flagsZ
name_appearedZ
name_vanishedZname_appeared_closureZname_vanished_closure�registration_idr
r
r�
watch_name0s0����zGLibMonitoring.watch_namecCs|\}}||g|�R�dS)zCallback for watch_name..Nr
)rrrZ
name_ownerr�callback�
callback_argsr
r
rrQsz&GLibMonitoring._name_appeared_callbackcCs|\}}||�dS)zCallback for watch_name.Nr
)rrrrrrr
r
rrZsz&GLibMonitoring._name_vanished_callbackcCst�|�dS)z5Stops watching a service name on the DBus connection.N)rZbus_unwatch_name)rrrr
r
rrcszGLibMonitoring._unwatch_name)
r	r
rr�classmethodrrrrrr
r
r
rr-s� 

rc@s�eZdZdZefdd�Zedd��Zedd��Zedd	��Z	ed
d��Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd S)!ra4Base class for DBus observers.

    This class is recommended to use only to watch the availability
    of a service on DBus. It doesn't provide any support for accessing
    objects provided by the service.

    Usage:

    .. code-block:: python

        # Create the observer and connect to its signals.
        observer = DBusObserver(SystemBus, "org.freedesktop.NetworkManager")

        def callback1(observer):
            print("Service is available!")

        def callback2(observer):
            print("Service is unavailable!")

        observer.service_available.connect(callback1)
        observer.service_unavailable.connect(callback2)

        # Connect to the service once it is available.
        observer.connect_once_available()

        # Disconnect the observer.
        observer.disconnect()

    cCs2||_||_d|_t�|_t�|_||_g|_dS)z�Creates a DBus service observer.

        :param message_bus: a message bus
        :param service_name: a DBus name of a service
        FN)�_message_bus�
_service_name�_is_service_availabler�_service_available�_service_unavailable�_monitoring�_subscriptions)�selfZmessage_bus�service_nameZ
monitoringr
r
r�__init__�szDBusObserver.__init__cCs|jS)zReturns a DBus name.�r�r#r
r
rr$�szDBusObserver.service_namecCs|jS)zThe proxy can be accessed.)rr'r
r
r�is_service_available�sz!DBusObserver.is_service_availablecCs|jS)z�Signal that emits when the service is available.

        Signal emits this class as an argument. You have to
        call the watch method to activate the signals.
        )rr'r
r
r�service_available�szDBusObserver.service_availablecCs|jS)z�Signal that emits when the service is unavailable.

        Signal emits this class as an argument. You have to
        call the watch method to activate the signals.
        )r r'r
r
r�service_unavailable�sz DBusObserver.service_unavailablecCs|��dS)z�Connect to the service once it is available.

        The observer is not connected to the service until it
        emits the service_available signal.
        N)�_watchr'r
r
r�connect_once_available�sz#DBusObserver.connect_once_availablecCs|��|jr|��dS)z�Disconnect from the service.

        Disconnect from the service if it is connected and stop
        watching its availability.
        N)�_unwatchr(�_disable_servicer'r
r
r�
disconnect�szDBusObserver.disconnectcCs.|j�|jj|jt|j|j�}|j�	|�dS)zWatch the service name on DBus.N)
r!rrrr$r�_service_name_appeared_callback�_service_name_vanished_callbackr"�append)r#Zsubscriptionr
r
rr+�s�zDBusObserver._watchcCs|jr|j��}|�qdS)z'Stop to watch the service name on DBus.N)r"�pop)r#rr
r
rr-�s
zDBusObserver._unwatchcCsd|_|j�|�dS)zEnable the service.TN)rr�emitr'r
r
r�_enable_service�szDBusObserver._enable_servicecCsd|_|j�|�dS)zDisable the service.FN)rr r4r'r
r
rr.�szDBusObserver._disable_servicecGs|js|��dS�zCallback for the watch method.N)r(r5�r#�argsr
r
rr0�sz,DBusObserver._service_name_appeared_callbackcGs|jr|��dSr6)r(r.r7r
r
rr1�sz,DBusObserver._service_name_vanished_callbackcCs|jS)z(Returns a string version of this object.r&r'r
r
r�__str__�szDBusObserver.__str__cCsd�|jj|j�S)z Returns a string representation.z{}({}))�format�	__class__r	rr'r
r
r�__repr__�s�zDBusObserver.__repr__N)r	r
rrrr%�propertyr$r(r)r*r,r/r+r-r5r.r0r1r9r<r
r
r
rris(



r)Zlogging�	functoolsrZdasbus.constantsrZ
dasbus.signalrZgiZrequire_versionZ
gi.repositoryrZ	getLoggerr	�log�__all__�	Exceptionr�objectrrr
r
r
r�<module>s
<