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: //usr/lib/python3.9/site-packages/dasbus/client/__pycache__/handler.cpython-39.pyc
a

װ_�=�@s�ddlmZmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZmZmZdd	lZe�d
d�e�dd�dd
lmZmZgd�ZGdd�de�ZGdd�ded�ZGdd�de�Zd	S)�)�ABCMeta�abstractmethod)�partial)�
PropertyProxy)�ErrorMapper)�Signal)�DBUS_FLAG_NONE��DBusSpecification)�get_variant�get_variant_type�unwrap_variantN�Gioz2.0�GLib)rr)�
GLibClient�AbstractClientObjectHandler�ClientObjectHandlerc@s�eZdZdZejZeeefdd��Z	edeefdd��Z
edd��Zedefd	d
��Zedd��Z
ed
d��Zedd��Zedd��Zedd��ZdS)rz0The low-level DBus client library based on GLib.c

Cs|�||||||||	d�	S)zVSynchronously call a DBus method.

        :return: a result of the DBus call
        N)Z	call_sync)
�cls�
connection�service_name�object_path�interface_name�method_name�
parameters�
reply_type�flags�timeout�r�9/usr/lib/python3.9/site-packages/dasbus/client/handler.py�	sync_call1s�zGLibClient.sync_callrcCs(|j|||||||
||j||	fd�
dS)z"Asynchronously call a DBus method.��callback�	user_dataN)�call�_async_call_finish)rrrrrrrrr!�
callback_argsrrrrr�
async_callEs�zGLibClient.async_callcs&|\}}|��fdd�g|�R�dS)z(Finish an asynchronous DBus method call.cs
����S�N)Zcall_finishr��
result_object�
source_objectrr�<lambda>`�z/GLibClient._async_call_finish.<locals>.<lambda>Nr)rr*r)r"r!r%rr(rr$Xs��zGLibClient._async_call_finishc	

Cs.|j||||d||j||fd�}	t|j||	�S)zKSubscribe to a signal.

        :return: a callback to unsubscribe
        Nr )Zsignal_subscribe�_signal_callbackr�_unsubscribe_signal)
rrrrr�signal_namer!r%r�subscription_idrrr�subscribe_signalds��zGLibClient.subscribe_signalc
Cs|\}}	||g|	�R�dS�z8A callback that is called when a DBus signal is emitted.Nr)
rrZsender_namerrr/rr"r!r%rrrr-}szGLibClient._signal_callbackcCs|�|�dS)zUnsubscribe from a signal.N)Zsignal_unsubscribe)rrr0rrrr.�szGLibClient._unsubscribe_signalcCst|tj�otj�|�S)zIs it a remote DBus error?)�
isinstancer�Errorr�	DBusError�is_remote_error�r�errorrrrr6�s
�zGLibClient.is_remote_errorcCstj�|�S)z)Get a DBus name of the remote DBus error.)rr5Zget_remote_errorr7rrr�get_remote_error_name�sz GLibClient.get_remote_error_namecCs:|�|�}|j}d�d|�}|�|�r6|t|�d�S|S)z'Get a message of the remote DBus error.z{}:{}: zGDBus.ErrorN)r9�message�format�
startswith�len)rr8�namer:�prefixrrr�get_remote_error_message�s

z#GLibClient.get_remote_error_messageN)�__name__�
__module__�__qualname__�__doc__rZMAXINTZDBUS_TIMEOUT_NONE�classmethodrrr&r$r1r-r.r6r9r@rrrrr+s2��
�
	


rc@s�eZdZdZgd�Zdd�Zedd��Zedd��Zed	d
��Z	e
dd��Zd
d�Zdd�Z
dd�Ze
dd��Ze
dd��Ze
dd��Ze
dd��ZdS)rz-The abstract handler of a remote DBus object.��_message_bus�
_service_name�_object_path�_specificationcCs||_||_||_d|_dS)z�Create a new handler.

        :param message_bus: a message bus
        :param service_name: a DBus name of the service
        :param object_path: a DBus path the object
        NrF)�self�message_busrrrrr�__init__�sz$AbstractClientObjectHandler.__init__cCs|jS)z9DBus service name.

        :return: a DBus name
        )rH�rKrrrr�sz(AbstractClientObjectHandler.service_namecCs|jS)z8DBus object path.

        :return: a DBus path
        )rIrNrrrr�sz'AbstractClientObjectHandler.object_pathcCs|js|��|_|jS)zDBus specification.)rJ�_get_specificationrNrrr�
specification�s
z)AbstractClientObjectHandler.specificationcCst�S)zKIntrospect the DBus object.

        :return: a DBus specification
        r	rNrrrrO�sz.AbstractClientObjectHandler._get_specificationcCs"|�||�}|�t|��}||�S)z�Create a member of the DBus object.

        :param interface_name: a name of the interface
        :param member_name: a name of the member
        :return: a signal, a method or a property
        )�_find_member_spec�
_find_handler�type)rKr�member_name�specZhandlerrrr�
create_member�sz)AbstractClientObjectHandler.create_membercCs|j�||�S)z�Find a specification of the DBus member.

        :param interface_name: a name of the interface
        :param member_name: a name of the member
        :return: a specification of the member
        )rPZ
get_member)rKrrTrrrrQ�s�z-AbstractClientObjectHandler._find_member_speccCsD|tjur|jS|tjur |jS|tjur0|jStd�|j	���dS)z�Find a handler for the given member type.

        :param member_type: a type of the member
        :return: a callback
        zUnsupported type: {}N)
r
ZProperty�
_get_propertyZMethod�_get_methodr�_get_signal�	TypeErrorr;rA)rK�member_typerrrrR�s



�z)AbstractClientObjectHandler._find_handlercCsdS)z�Get a proxy of the DBus property.

        :param property_spec: a property_specification
        :return: a property object
        Nr)rK�
property_specrrrrWsz)AbstractClientObjectHandler._get_propertycCsdS)zGet a proxy of the DBus method.

        :param method_spec: a method specification
        :return: a callable object
        Nr�rKZmethod_specrrrrXsz'AbstractClientObjectHandler._get_methodcCsdS)z}Get a proxy of the DBus signal.

        :param signal_spec: a signal specification
        :return: a signal object
        Nr)rK�signal_specrrrrYsz'AbstractClientObjectHandler._get_signalcCsdS)z�Disconnect members of the DBus object.

        Unsubscribe from DBus signals and disconnect all
        registered callbacks of the proxy signals.
        NrrNrrr�disconnect_memberssz.AbstractClientObjectHandler.disconnect_membersN)rArBrCrD�	__slots__rM�propertyrrrPrrOrVrQrRrWrXrYr_rrrrr�s,






r)�	metaclasscs�eZdZdZgd�Zdeef�fdd�	Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z�ZS) rz$The client handler of a DBus object.)�_client�_signal_factory�
_error_mapper�_subscriptionsNcs2t��|||�||_||_|p$t�|_g|_dS)aBCreate a new handler.

        :param message_bus: a message bus
        :param service_name: a DBus name of the service
        :param object_path: a DBus path the object
        :param error_mapper: a DBus error mapper
        :param client: a DBus client library
        :param signal_factory: a signal factory
        N)�superrMrcrdrrerf)rKrLrrZerror_mapperZclientZsignal_factory��	__class__rrrM2s
zClientObjectHandler.__init__cCs|�dddd�}t�|�S)zIntrospect the DBus object.z#org.freedesktop.DBus.IntrospectableZ
IntrospectNz(s))�_call_methodr
Zfrom_xml)rKZxmlrrrrODs�z&ClientObjectHandler._get_specificationc	CsR|��}|jj|jj|j|j|j|j|j	|j
fd�}|j�|�|j�|j
�|S)zGet a proxy of the DBus signal.�r!r%)rdrcr1rGrrHrIrr>r-�emitrf�appendZ
disconnect)rKr^�signalZunsubscriberrrrYOs�zClientObjectHandler._get_signalcCs|t|��dSr2)r
)rKrr!rrrr-esz$ClientObjectHandler._signal_callbackcCs6d}d}|jrt|j|�}|jr,t|j|�}t||�S)z!Get a proxy of the DBus property.N)�readabler�_get_property_value�writable�_set_property_valuer)rKr\�getter�setterrrrrWisz!ClientObjectHandler._get_propertycCs |�dddd|j|j�}t|�S)z!Get a value of the DBus property.�org.freedesktop.DBus.PropertiesZGetz(ss)z(v))rjrr>r
)rKr\Zvariantrrrrpvs�z'ClientObjectHandler._get_property_valuecCs"|�dddd|j|jt|j|��S)z!Set a value of the DBus property.ru�Setz(ssv)N)rjrr>rrS)rKr\Zproperty_valuerrrrr�s
�z'ClientObjectHandler._set_property_valuecCst|j|j|j|j|j�S)z(Get a callable proxy of the DBus method.)rrjrr>�in_type�out_typer]rrrrX�s�zClientObjectHandler._get_methodcOs�|sd}|durt||�}d}|dur.t|�}|jj|j|j||||f}|�dd�}	|�dt��}
|	s�|j|j	j
g|�Ri|��S|j	j|i|�|j|	|
fd���SdS)zKCall a DBus method.

        :return: a result of the call or None
        Nr!r%rk)
rrrGrrHrI�pop�tuple�_get_method_replyrcrr&�_method_callback)rKrrrwrxr�kwargsr�argsr!r%rrrrj�sB
�������z ClientObjectHandler._call_methodcs|��fdd�g|�R�dS)z/A callback of an asynchronous DBus method call.cs
����Sr')r{r�rsrKrrr+�r,z6ClientObjectHandler._method_callback.<locals>.<lambda>Nr)rKrsr!r%rrrr|�s
��z$ClientObjectHandler._method_callbackc
OsNz||i|��}|�|�WStyH}z|�|�WYd}~Sd}~00dS)aGet a result of a DBus call.

        :param call: a callback
        :param args: arguments of the callback
        :param kwargs: keyword arguments of the callback
        :return: a result of the callback
        :raise: an exception raised by the callback
        N)�_handle_method_result�	Exception�_handle_method_error)rKr#r~r}�resultr8rrrr{�s
	z%ClientObjectHandler._get_method_replycCsL|j�|�s|�|j�|�}|j�|�}|j�|�}||�}||_|d�dS)zcHandle an error of a DBus call.

        :param error: an exception raised during the call
        N)rcr6r9reZget_exception_typer@Z	dbus_name)rKr8r>rr:�	exceptionrrrr��sz(ClientObjectHandler._handle_method_errorcCs(t|�}|sdSt|�dkr$|dS|S)zPHandle a result of a DBus call.

        :param result: a variant tuple
        N�r)r
r=)rKr��valuesrrrr��sz)ClientObjectHandler._handle_method_resultcCs|jr|j��}|�qdS)z&Disconnect members of the DBus object.N)rfry)rKr!rrrr_s
z&ClientObjectHandler.disconnect_members)rArBrCrDr`rrrMrOrYr-rWrprrrXrjr|r{r�r�r_�
__classcell__rrrhrr(s$�

1r)�abcrr�	functoolsrZdasbus.client.propertyrZdasbus.errorrZ
dasbus.signalrZdasbus.constantsrZdasbus.specificationr
Z
dasbus.typingrrr
ZgiZrequire_versionZ
gi.repositoryrr�__all__�objectrrrrrrr�<module>s y