관리-도구
편집 파일: observer.cpython-39.opt-1.pyc
a ����װ_[����������������������@���s����d�dl�Z�d�dlmZ�d�dlmZ�d�dlmZ�d�dlZe�dd��d�dl m Z �e��e�Z g�d�ZG�d d ��d e�ZG�dd��de�ZG�d d��de�ZdS�)�����N)�partial)�DBUS_FLAG_NONE)�Signal�Gioz2.0)r���)�DBusObserverError�DBusObserver�GLibMonitoringc�������������������@���s���e�Zd�ZdZdS�)r���z'Exception class for the DBus observers.N)�__name__� __module__�__qualname__�__doc__��r ���r ����:/usr/lib/python3.9/site-packages/dasbus/client/observer.pyr���(���s���r���c�������������������@���sH���e�Zd�ZdZeeddfdd��Zedd���Zedd���Zed d ���Z dS�)r���z4The low-level DBus monitoring library based on GLib.Nc����������� ������C���sT���d}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_callbackr���Zbus_watch_name_on_connection� _unwatch_name) �cls� connection�name�flagsZ name_appearedZ name_vanishedZname_appeared_closureZname_vanished_closure�registration_idr ���r ���r���� watch_name0���s0��������zGLibMonitoring.watch_namec�����������������C���s���|\}}||g|�R����dS�)zCallback for watch_name..Nr ���)r���r���r���Z name_ownerr����callback� callback_argsr ���r ���r���r���Q���s����z&GLibMonitoring._name_appeared_callbackc�����������������C���s���|\}}||���dS�)zCallback for watch_name.Nr ���)r���r���r���r���r���r���r ���r ���r���r���Z���s����z&GLibMonitoring._name_vanished_callbackc�����������������C���s���t��|��dS�)z5Stops watching a service name on the DBus connection.N)r���Zbus_unwatch_name)r���r���r���r ���r ���r���r���c���s����zGLibMonitoring._unwatch_name) r ���r ���r���r����classmethodr���r���r���r���r���r ���r ���r ���r���r���-���s���� r���c�������������������@���s����e�Zd�ZdZefdd�Zedd���Zedd���Zedd ���Z ed d���Z dd ��Zdd��Zdd��Z dd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zd S�)!r���a4��Base 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() c�����������������C���s2���||�_�||�_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__����s����zDBusObserver.__init__c�����������������C���s���|�j�S�)zReturns a DBus name.�r����r#���r ���r ���r���r$�������s����zDBusObserver.service_namec�����������������C���s���|�j�S�)zThe proxy can be accessed.)r���r'���r ���r ���r����is_service_available����s����z!DBusObserver.is_service_availablec�����������������C���s���|�j�S�)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. )r���r'���r ���r ���r����service_available����s����zDBusObserver.service_availablec�����������������C���s���|�j�S�)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����s����z DBusObserver.service_unavailablec�����������������C���s���|������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����s����z#DBusObserver.connect_once_availablec�����������������C���s���|������|�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����s����zDBusObserver.disconnectc�����������������C���s.���|�j��|�jj|�jt|�j|�j�}|�j� |��dS�)zWatch the service name on DBus.N) r!���r���r���r���r$���r����_service_name_appeared_callback�_service_name_vanished_callbackr"����append)r#���Zsubscriptionr ���r ���r���r+�������s�����zDBusObserver._watchc�����������������C���s���|�j�r|�j����}|���q�dS�)z'Stop to watch the service name on DBus.N)r"����pop)r#���r���r ���r ���r���r-�������s���� zDBusObserver._unwatchc�����������������C���s���d|�_�|�j�|���dS�)zEnable the service.TN)r���r����emitr'���r ���r ���r����_enable_service����s����zDBusObserver._enable_servicec�����������������C���s���d|�_�|�j�|���dS�)zDisable the service.FN)r���r ���r4���r'���r ���r ���r���r.�������s����zDBusObserver._disable_servicec�����������������G���s���|�j�s|�����dS��zCallback for the watch method.N)r(���r5����r#����argsr ���r ���r���r0�������s����z,DBusObserver._service_name_appeared_callbackc�����������������G���s���|�j�r|�����dS�r6���)r(���r.���r7���r ���r ���r���r1�������s����z,DBusObserver._service_name_vanished_callbackc�����������������C���s���|�j�S�)z(Returns a string version of this object.r&���r'���r ���r ���r����__str__����s����zDBusObserver.__str__c�����������������C���s���d��|�jj|�j�S�)z Returns a string representation.z{}({}))�format� __class__r ���r���r'���r ���r ���r����__repr__����s�����zDBusObserver.__repr__N)r ���r ���r���r���r���r%����propertyr$���r(���r)���r*���r,���r/���r+���r-���r5���r.���r0���r1���r9���r<���r ���r ���r ���r���r���i���s(��� r���)Zlogging� functoolsr���Zdasbus.constantsr���Z dasbus.signalr���ZgiZrequire_versionZ gi.repositoryr���Z getLoggerr ����log�__all__� Exceptionr����objectr���r���r ���r ���r ���r����<module>���s��� <