관리-도구
편집 파일: proxies.cpython-39.opt-1.pyc
a ����� z]�`����������������������@���s����d�dl�Z�zd�dlmZ�W�n�ey6���d�dlmZ�Y�n0�d�dlZd�dlmZ�d�dlm Z m Z mZmZ�dZ e��d�Zd�dlmZmZmZmZmZ�d�dlmZ�G�d d ��d �ZG�dd��d�ZG�d d��de�ZG�dd��de�ZdS�)�����N)�RLock)�process_introspection_data)� DBusException�IntrospectionParserException�MissingErrorHandlerException�MissingReplyHandlerExceptionZrestructuredtextzdbus.proxies)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�INTROSPECTABLE_IFACE� LOCAL_PATH)�is_py2c�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) �_DeferredMethodzXA proxy method which will only get called once we have its introspection reply. c�����������������C���s���||�_�|j|�_||�_||�_d�S��N)� _proxy_method�_method_name�_append�_block)�self�proxy_method�append�block��r����2/usr/lib64/python3.9/site-packages/dbus/proxies.py�__init__8���s����z_DeferredMethod.__init__c�����������������O���sD���d|v�s|��dd�r(|��|�j||��d�S�|�����|�j|i�|��S�d�S�)N� reply_handler�ignore_replyF)�getr���r���r����r����args�keywordsr���r���r����__call__?���s���� �z_DeferredMethod.__call__c�����������������O���s���|���|�j||��d�S�r���)r���r���r���r���r���r���� call_asyncJ���s����z_DeferredMethod.call_asyncN��__name__� __module__�__qualname__�__doc__r���r!���r"���r���r���r���r���r���4���s���r���c�������������������@���s(���e�Zd�ZdZdd��Zdd��Zdd��ZdS�) �_ProxyMethodz�A proxy method. Typically a member of a ProxyObject. Calls to the method produce messages that travel over the Bus and are routed to a specific named Service. c�����������������C���sX���|t�krtdt����||�_||�_||�_||�_t�|��||�_|d�urNt� |��||�_ d�S�)Nz1Methods may not be called on the reserved path %s)r���r����_proxy�_connection�_named_service�_object_path�_dbus_bindingsZvalidate_member_namer���Zvalidate_interface_name�_dbus_interface)r����proxyZ connection�bus_name�object_pathZmethod_nameZifacer���r���r���r���U���s����� z_ProxyMethod.__init__c����������� ��� ���O���s��|��dd��}|��dd��}|��dd�}|��dd��}|d�us@|d�url|d�u�rPt���n|d�u�r`t���n|rltd��|��d|�j�}|d�u�r�|d�u�r�|�j}n|d�|�j�}|�jj�|d��}|s�|d�ur�|�j j |�j|�j||�j||||fi�|���n$|�j j |�j|�j||�j||fi�|��S�d�S�) Nr���� error_handlerr���F� signaturez6ignore_reply and reply_handler cannot be used together�dbus_interface�.)�popr���r���� TypeErrorr.���r���r)����_introspect_method_mapr���r*���r"���r+���r,���Z call_blocking) r���r���r ���r���r2���r���r3���r4����keyr���r���r���r!���i���sL���� �� ��z_ProxyMethod.__call__c�������������� ���O���s����|��dd��}|��dd��}|��dd��}|��d|�j�}|d�u�rd|rN|d�|�j�}n|�j}|�jj�|d��}|�jj|�j|�j ||�j||||fi�|���d�S�)Nr���r2���r3���r4���r5���) r6���r.���r���r)���r8���r���r*���r"���r+���r,���)r���r���r ���r���r2���r3���r4���r9���r���r���r���r"�������s(���� ��z_ProxyMethod.call_asyncNr#���r���r���r���r���r(���N���s���,r(���c�������������������@���s����e�Zd�ZdZeZeZdZdZ dZ d%dd �Zed d��ddd�Z ed d��ddd�Zedd��ddd�Zd&dd�Zdd��Zdd��Zdd��Zdd��Zdd��Zdd��Zdd ��Zd'd!d"�Zd#d$��ZeZdS�)(�ProxyObjectz�A proxy to the remote Object. A ProxyObject is provided by the Bus. ProxyObjects have member functions, and can be called like normal Python objects. r�����������NTFc����������� ������K���s:��|��dd�}|durB|dur$td��|}ddlm}�|dtdd��|��d d�} | dur�|durftd ��| }ddlm}�|dtdd��|r�tdd �|�������|r�|����||�_|dur�t � |��|�|�_|�_t � |��||�_|s�|�|�|�_d|�_g�|�_i�|�_t��|�_|�r|�jtk�r$|�j|�_n|�j|�_|����|�_dS�)a���Initialize the proxy object. :Parameters: `conn` : `dbus.connection.Connection` The bus or connection on which to find this object. The keyword argument `bus` is a deprecated alias for this. `bus_name` : str A bus name for the application owning the object, to be used as the destination for method calls and the sender for signal matches. The keyword argument ``named_service`` is a deprecated alias for this. `object_path` : str The object path at which the application exports the object `introspect` : bool If true (default), attempt to introspect the remote object to find out supported methods and their signatures `follow_name_owner_changes` : bool If true (default is false) and the `bus_name` is a well-known name, follow ownership changes for that name �busNz%conn and bus cannot both be specifiedr���)�warnz`Passing the bus parameter to ProxyObject by name is deprecated: please use positional parametersr<���)� stacklevel� named_servicez3bus_name and named_service cannot both be specifiedzjPassing the named_service parameter to ProxyObject by name is deprecated: please use positional parametersz>ProxyObject.__init__ does not take these keyword arguments: %sz, )r6���r7����warningsr>����DeprecationWarning�join�keysZ_require_main_loop�_busr-���Zvalidate_bus_namer+����_requested_bus_nameZvalidate_object_path�__dbus_object_path__Zactivate_name_owner�_pending_introspect�_pending_introspect_queuer8���r����_introspect_lockr���� INTROSPECT_STATE_DONT_INTROSPECT�_introspect_state�'INTROSPECT_STATE_INTROSPECT_IN_PROGRESS�_Introspect) r���Zconnr0���r1���Z introspectZfollow_name_owner_changes�kwargsr=���r>���r@���r���r���r���r�������sP������� zProxyObject.__init__c�����������������C���s���|�j�S�r���)r+����r���r���r���r����<lambda>�������zProxyObject.<lambda>a���The bus name to which this proxy is bound. (Read-only, may change.) If the proxy was instantiated using a unique name, this property is that unique name. If the proxy was instantiated with a well-known name and with ``follow_name_owner_changes`` set false (the default), this property is the unique name of the connection that owned that well-known name when the proxy was instantiated, which might not actually own the requested well-known name any more. If the proxy was instantiated with a well-known name and with ``follow_name_owner_changes`` set true, this property is that well-known name. c�����������������C���s���|�j�S�r���)rF���rP���r���r���r���rQ��� ��rR���z[The bus name which was requested when this proxy was instantiated. c�����������������C���s���|�j�S�r���)rG���rP���r���r���r���rQ���&��rR���zThe object-path of this proxy.c�����������������K���s"���|�j�j|f|||�j|�jd�|��S�)ax��Arrange for the given function to be called when the given signal is received. :Parameters: `signal_name` : str The name of the signal `handler_function` : callable A function to be called when the signal is emitted by the remote object. Its positional arguments will be the arguments of the signal; optionally, it may be given keyword arguments as described below. `dbus_interface` : str Optional interface with which to qualify the signal name. If None (the default) the handler will be called whenever a signal of the given member name is received, whatever its interface. :Keywords: `utf8_strings` : bool If True, the handler function will receive any string arguments as dbus.UTF8String objects (a subclass of str guaranteed to be UTF-8). If False (default) it will receive any string arguments as dbus.String objects (a subclass of unicode). `byte_arrays` : bool If True, the handler function will receive any byte-array arguments as dbus.ByteArray objects (a subclass of str). If False (default) it will receive any byte-array arguments as a dbus.Array of dbus.Byte (subclasses of: a list of ints). `sender_keyword` : str If not None (the default), the handler function will receive the unique name of the sending endpoint as a keyword argument with this name `destination_keyword` : str If not None (the default), the handler function will receive the bus name of the destination (or None if the signal is a broadcast, as is usual) as a keyword argument with this name. `interface_keyword` : str If not None (the default), the handler function will receive the signal interface as a keyword argument with this name. `member_keyword` : str If not None (the default), the handler function will receive the signal name as a keyword argument with this name. `path_keyword` : str If not None (the default), the handler function will receive the object-path of the sending object as a keyword argument with this name `message_keyword` : str If not None (the default), the handler function will receive the `dbus.lowlevel.SignalMessage` as a keyword argument with this name. `arg...` : unicode or UTF-8 str If there are additional keyword parameters of the form ``arg``\ *n*, match only signals where the *n*\ th argument is the value given for that keyword parameter. As of this time only string arguments can be matched (in particular, object paths and signatures can't). )�signal_namer4���r0����path)rE���Zadd_signal_receiverr+���rG����r���rS���Zhandler_functionr4���r ���r���r���r����connect_to_signal2��s����< ���zProxyObject.connect_to_signalc�������������� ���C���s>���i�}t�rd|d<�|�jj|�j|�jtddd|�j|�jfddi|��S�)NTZutf8_stringsZ Introspect��r���Zrequire_main_loopF)r ���rE���r"���r+���rG���r����_introspect_reply_handler�_introspect_error_handler)r���rO���r���r���r���rN���u��s���� ���zProxyObject._Introspectc�����������������C���s*���|�j�D�]\}}}||i�|���qg�|�_�d�S�r���)rI���)r���r���r���r ���r���r���r����_introspect_execute_queue���s����z%ProxyObject._introspect_execute_queuec�������������� ���C���s����|�j�����zpzt|�|�_W�n<�tyV�}�z$|��|��W�Y�d�}~W�|�j�����d�S�d�}~0�0�|�j|�_d�|�_ |�� ���W�|�j�����n|�j�����0�d�S�r���)rJ����acquirer���r8���r���rY����release� INTROSPECT_STATE_INTROSPECT_DONErL���rH���rZ���)r����data�er���r���r���rX������s���� � z%ProxyObject._introspect_reply_handlerc�����������������C���sr���t�����t�d|�j|�j|jj|jj|��|�j � ���z.t�d��|�j|�_ d�|�_|�����W�|�j ����n|�j ����0�d�S�)Nz$Introspect error on %s:%s: %s.%s: %sz'Executing introspect queue due to error)�loggingZbasicConfig�_logger�errorr+���rG���� __class__r%���r$���rJ���r[����debugrK���rL���rH���rZ���r\���)r���rb���r���r���r���rY������s����� z%ProxyObject._introspect_error_handlerc�����������������C���s>���|�j�����z"|�jd�ur |�j����W�|�j�����n|�j�����0�d�S�r���)rJ���r[���rH���r���r\���rP���r���r���r����_introspect_block���s ���� zProxyObject._introspect_blockc�����������������C���sX���|�j�����z<|�j|�jkr,|�j�|||f��n||i�|���W�|�j�����n|�j�����0�d�S�r���)rJ���r[���rL���rM���rI���r���r\���)r����callbackr���rO���r���r���r����_introspect_add_to_queue���s���� z$ProxyObject._introspect_add_to_queuec�����������������C���s,���|��d�r|�d�rt|��n |��|�S�d�S��N�__)� startswith�endswith�AttributeError�get_dbus_method�r����memberr���r���r����__getattr__���s���� zProxyObject.__getattr__c�����������������C���s<���|���|�|�j|�j|�j||�}|�j|�jkr8|��||�j|�j�}|S�)a,��Return a proxy method representing the given D-Bus method. The returned proxy method can be called in the usual way. For instance, :: proxy.get_dbus_method("Foo", dbus_interface='com.example.Bar')(123) is equivalent to:: proxy.Foo(123, dbus_interface='com.example.Bar') or even:: getattr(proxy, "Foo")(123, dbus_interface='com.example.Bar') However, using `get_dbus_method` is the only way to call D-Bus methods with certain awkward names - if the author of a service implements a method called ``connect_to_signal`` or even ``__getattr__``, you'll need to use `get_dbus_method` to call them. For services which follow the D-Bus convention of CamelCaseMethodNames this won't be a problem. ) �ProxyMethodClassrE���r+���rG���rL���rM����DeferredMethodClassrg���re���)r���ro���r4����retr���r���r���rm������s���� � �zProxyObject.get_dbus_methodc�����������������C���s���d|�j�|�j|�jt|��f�S�)Nz&<ProxyObject wrapping %s %s %s at %#x>)rE���r+���rG����idrP���r���r���r����__repr__���s�����zProxyObject.__repr__)NNNTF)N)N)r$���r%���r&���r'���r(���rq���r���rr���rK���rM���r]���r����propertyr0����requested_bus_namer1���rV���rN���rZ���rX���rY���re���rg���rp���rm���ru����__str__r���r���r���r���r:�������s>������ S��� C &r:���c�������������������@���s����e�Zd�ZdZdd��Zedd��ddd�ZeZedd��ddd �Zed d��ddd�Z edd��ddd �Z edd��ddd�Zddd�Zdd��Z ddd�Zdd��ZeZdS�)� Interfacez�An interface into a remote object. An Interface can be used to wrap ProxyObjects so that calls can be routed to their correct D-Bus interface. c�����������������C���s$���t�|t�r|j|�_n||�_||�_dS�)a:��Construct a proxy for the given interface on the given object. :Parameters: `object` : `dbus.proxies.ProxyObject` or `dbus.Interface` The remote object or another of its interfaces `dbus_interface` : str An interface the `object` implements N)� isinstancery����proxy_object�_objr.���)r����objectr4���r���r���r���r������s���� zInterface.__init__c�����������������C���s���|�j�jS�r���)r|���r1���rP���r���r���r���rQ�����rR���zInterface.<lambda>Nz.The D-Bus object path of the underlying objectc�����������������C���s���|�j�jS�r���)r|���r0���rP���r���r���r���rQ�����rR���z:The bus name to which the underlying proxy object is boundc�����������������C���s���|�j�jS�r���)r|���rw���rP���r���r���r���rQ�����rR���zGThe bus name which was requested when the underlying object was createdc�����������������C���s���|�j�S�r���)r|���rP���r���r���r���rQ�����rR���zThe underlying proxy objectc�����������������C���s���|�j�S�r���)r.���rP���r���r���r���rQ�����rR���zThe D-Bus interface representedc�����������������K���s"���|s |�j�}|�jj|||fi�|��S�)aa��Arrange for a function to be called when the given signal is emitted. The parameters and keyword arguments are the same as for `dbus.proxies.ProxyObject.connect_to_signal`, except that if `dbus_interface` is None (the default), the D-Bus interface that was passed to the `Interface` constructor is used. )r.���r|���rV���rU���r���r���r���rV�����s���� ��zInterface.connect_to_signalc�����������������C���s2���|��d�r|�d�rt|��n|�j�||�j�S�d�S�rh���)rj���rk���rl���r|���rm���r.���rn���r���r���r���rp���$��s���� zInterface.__getattr__c�����������������C���s���|du�r|�j�}|�j�||�S�)a&��Return a proxy method representing the given D-Bus method. This is the same as `dbus.proxies.ProxyObject.get_dbus_method` except that if `dbus_interface` is None (the default), the D-Bus interface that was passed to the `Interface` constructor is used. N)r.���r|���rm���)r���ro���r4���r���r���r���rm���*��s����zInterface.get_dbus_methodc�����������������C���s���d|�j�|�jt|��f�S�)Nz%<Interface %r implementing %r at %#x>)r|���r.���rt���rP���r���r���r���ru���6��s�����zInterface.__repr__)N)N)r$���r%���r&���r'���r���rv���r1���rG���r0���rw���r{���r4���rV���rp���rm���ru���rx���r���r���r���r���ry������s2���������� ry���)r`���� threadingr����ImportErrorZdummy_threadingr-���Zdbus._expat_introspect_parserr���Zdbus.exceptionsr���r���r���r���Z __docformat__Z getLoggerra���r���r ���r ���r���r���Zdbus._compatr ���r���r(���r}���r:���ry���r���r���r���r����<module>���s"��� `��B