@ia` ddlZ ddlmZddlZddlmZddlm Z m Z m Z m Z dZ ejdZddlmZmZmZmZmZddlmZGd d ZGd d ZGd deZGddeZy#e$r ddlmZYvwxYw)N)RLock)process_introspection_data) DBusExceptionIntrospectionParserExceptionMissingErrorHandlerExceptionMissingReplyHandlerExceptionrestructuredtextz dbus.proxies)BUS_DAEMON_IFACEBUS_DAEMON_NAMEBUS_DAEMON_PATHINTROSPECTABLE_IFACE LOCAL_PATH)is_py2c"eZdZdZdZdZdZy)_DeferredMethodzXA proxy method which will only get called once we have its introspection reply. cP||_|j|_||_||_yN) _proxy_method _method_name_append_block)self proxy_methodappendblocks ./usr/lib/python3/dist-packages/dbus/proxies.py__init__z_DeferredMethod.__init__8s&)(55  cd|vs|jddr|j|j||y|j|j|i|S)N reply_handler ignore_replyF)getrrrrargskeywordss r__call__z_DeferredMethod.__call__?sT x ' LL / LL++T8 < KKM%4%%t8x8 8rc>|j|j||yr)rrr#s r call_asyncz_DeferredMethod.call_asyncJs T''x8rN__name__ __module__ __qualname____doc__rr&r(rrrr4s 99rrc"eZdZdZdZdZdZy) _ProxyMethodzA 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|tk(rtdtz||_||_||_||_t j|||_|t j|||_ y)Nz1Methods may not be called on the reserved path %s) rr_proxy _connection_named_service _object_path_dbus_bindingsvalidate_member_namervalidate_interface_name_dbus_interface)rproxy connectionbus_name object_path method_nameifaces rrz_ProxyMethod.__init__Usw * $!*,6!78 8 % )'*++K8*    2 25 9$rc |jdd}|jdd}|jdd}|jdd}||%| t| t|r td|jd|j}|G| |j }n|dz|j z}|j jj|d}|s|C|jj|j|j||j ||||fi|y|jj|j|j||j ||fi|S) Nr error_handlerr!F signaturez6ignore_reply and reply_handler cannot be used togetherdbus_interface.)poprr TypeErrorr9rr2_introspect_method_mapr"r3r(r4r5 call_blocking) rr$r%r rAr!rBrCkeys rr&z_ProxyMethod.__call__is| _d;  _d; ||NE: LLd3  $ (A$244&244!011"&68L8LM  %''$s*T->->> ::>>sDII =4 'D   ' '(;(;(,(9(9(6(,(9(9(1(,(5(5 4+3 424##11$2E2E262C2C2@262C2C2;26 > 5= > >rc |jdd}|jdd}|jdd}|jd|j}|G|r|dz|jz}n |j}|jjj |d}|j j|j|j||j||||fi|y)Nr rArBrCrD) rEr9rr2rGr"r3r(r4r5)rr$r%r rArBrCrIs rr(z_ProxyMethod.call_asyncs _d;  _d; LLd3 !&68L8LM  $s*T->->>'' ::>>sDII###D$7$7$($5$5$2$($5$5$-$($1$1 0'/ 0rNr)r.rrr0r0Ns %(*>X0rr0ceZdZdZeZeZdZdZ dZ ddZ e ddddZ e d ddd Ze d ddd Zdd ZdZdZdZdZdZdZdZddZdZeZy) ProxyObjectzA proxy to the remote Object. A ProxyObject is provided by the Bus. ProxyObjects have member functions, and can be called like normal Python objects. rNc |jdd}|$| td|}ddlm}|dtd|jd d} | $| td | }ddlm}|d td|r+td d j |j z|r|j||_|tj||x|_ |_ tj|||_|s|j||_ d|_g|_i|_t'|_|r|jt*k(r|j,|_y|j0|_|j3|_y)aInitialize 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 parametersrN) 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, )rErFwarningsrQDeprecationWarningjoinkeys_require_main_loop_busr6validate_bus_namer4_requested_bus_namevalidate_object_path__dbus_object_path__activate_name_owner_pending_introspect_pending_introspect_queuerGr_introspect_lockr INTROSPECT_STATE_DONT_INTROSPECT_introspect_state'INTROSPECT_STATE_INTROSPECT_IN_PROGRESS _Introspect) rconnr<r= introspectfollow_name_owner_changeskwargsrPrQrSs rrzProxyObject.__init__s,jj% ? GHHD % @# 3 ?D9  $#!,--$H % C# 3 4"ii 678 8 %  # # %    , ,X 6:BAd6++K8$/!("&":":8"DD $( )+&&(#!&T66*D%)%J%JD "%)%Q%QD "'+'7'7'9D $rc|jSr)r4rs rzProxyObject.s T%8%8raThe 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|jSr)r[rks rrlzProxyObject. s t/G/Grz[The bus name which was requested when this proxy was instantiated. c|jSr)r]rks rrlzProxyObject.&s (A(ArzThe object-path of this proxy.c n|jj|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_namerCr<path)rYadd_signal_receiverr4r]rrphandler_functionrCr%s rconnect_to_signalzProxyObject.connect_to_signal2sHx & %%&6 22=5C/3/B/B+/+D+D  2 )1  2 2rc i}|jj|j|jtddd|j |j fddi|S)N Introspectr.require_main_loopF)rYr(r4r]r _introspect_reply_handler_introspect_error_handler)rris rrezProxyObject._Introspectusf#tyy##D$7$7$($=$=$8,B$($B$B$($B$B G 7< G @F G GrcL|jD]\}}}||i|g|_yr)r`)rrr$r%s r_introspect_execute_queuez%ProxyObject._introspect_execute_queue~s5/3.L.L , *\4 $ +( + ,)+&rc|jj t||_|j|_d|_ |j|jj y#t$r5}|j |Yd}~|jj yd}~wwxYw#|jj wxYwr) raacquirerrGrr{release INTROSPECT_STATE_INTROSPECT_DONErcr_r})rdataes rrzz%ProxyObject._introspect_reply_handlers %%' , .H.N+ &*%J%JD "'+D $  * * ,  ! ! ) ) +0 ..q1  ! ! ) ) +   ! ! ) ) +s.A0(B10 B.9B) B1)B..B11C ctjtjd|j|j |j j|j j||jj tjd|j|_ d|_|j|jj!y#|jj!wxYw)Nz$Introspect error on %s:%s: %s.%s: %sz'Executing introspect queue due to error)logging basicConfig_loggererrorr4r] __class__r+r*rardebugrbrcr_r}r)rrs rr{z%ProxyObject._introspect_error_handlers <))4+D+Doo00%//2J2J  %%' , MMC D%)%J%JD "'+D $  * * ,  ! ! ) ) +D ! ! ) ) +s =CC:c|jj |j|jj|jj y#|jj wxYwr)rarr_rrrks r_introspect_blockzProxyObject._introspect_blocks^ %%' ,''3((..0  ! ! ) ) +D ! ! ) ) +s &AA9c,|jj |j|jk(r|jj |||fn||i||jj y#|jj wxYwr)rarrcrdr`rr)rcallbackr$ris r_introspect_add_to_queuez$ProxyObject._introspect_add_to_queues| %%' ,%%)U)UU..55xv6NO$)&)  ! ! ) ) +D ! ! ) ) +s AA77Bc~|jdr|jdr t||j|SN__) startswithendswithAttributeErrorget_dbus_methodrmembers r __getattr__zProxyObject.__getattr__s7   T "vt'< ( (''/ /rc|j||j|j|j||}|j|j k(r'|j ||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. ) ProxyMethodClassrYr4r]rcrdDeferredMethodClassrr)rrrCrets rrzProxyObject.get_dbus_methodst.##D$))$($7$7$($=$=v$24  ! !T%Q%Q Q**30M0M+/+A+ACC rcbd|j|j|jt|fzS)Nz&)rYr4r]idrks r__repr__zProxyObject.__repr__s47 IIt**D,E,Er$x9QQ Qr)NNNTFr)r*r+r,r-r0rrrrbrdrrpropertyr<requested_bus_namer=rurer}rzr{rrrrr__str__r.rrrLrLs $)'($./+'($=As)>)>rNz.The D-Bus object path of the underlying objectc.|jjSr)rr<rks rrlzInterface.sdii&8&8rz:The bus name to which the underlying proxy object is boundc.|jjSr)rrrks rrlzInterface. s 0L0LrzGThe bus name which was requested when the underlying object was createdc|jSr)rrks rrlzInterface. s $))rzThe underlying proxy objectc|jSr)r9rks rrlzInterface.s D,@,@rzThe D-Bus interface representedc \|s |j}|jj|||fi|S)aaArrange 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. )r9rrurss rruzInterface.connect_to_signals>!11N*tyy**;8H+9G=EG Grc|jdr|jdr t||jj ||j Sr)rrrrrr9rs rrzInterface.__getattr__"sC   T "vt'< ( (99,,VT5I5IJ JrcV| |j}|jj||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. )r9rr)rrrCs rrzInterface.get_dbus_method(s,  !!11Nyy((@@rcLd|j|jt|fzS)Nz%)rr9rrks rrzInterface.__repr__4s)6 4''D833 3rr)r*r+r,r-rrr=r]r<rrrCrurrrrr.rrrrs .>dLNK&8$$%H"#L#'$CD3T4>@L@$DFN*.G K A3Grr)r threadingr ImportErrordummy_threadingr6dbus._expat_introspect_parserrdbus.exceptionsrrrr __docformat__ getLoggerrr r r r r dbus._compatrrr0rrLrr.rrrs8&D""#  '  N + 994]0]0@{&{| KKY&%&sA55 BB