@iadZdZddlZddlZddlZddlZ ddlmZddl Z ddl m Z m Z mZmZmZmZmZddlmZmZddlmZmZmZddlmZmZmZdd lmZdd l m!Z!ejDd Z#Gd d e$Z%Gdde$Z&dZ'dZ(dZ)Gdde*Z+e+de$fiZ,e$Z-Gdde,Z.Gdde.Z/y#e$r ddl mZYwxYw))BusNameObjectFallbackObjectmethodsignalrestructuredtextN)Sequence)INTROSPECTABLE_IFACE ObjectPath SessionBus SignatureStructvalidate_bus_namevalidate_object_path)rr) DBusExceptionNameExistsExceptionUnknownMethodException) ErrorMessageMethodReturnMessageMethodCallMessage) LOCAL_PATH)is_py2z dbus.serviceceZdZdZdZdZy)_VariantSignaturezA fake method signature which, when iterated, yields an endless stream of 'v' characters representing variants (handy with zip()). It has no string representation. c|S)z Return self.selfs ./usr/lib/python3/dist-packages/dbus/service.py__iter__z_VariantSignature.__iter__>s cy)zReturn 'v' whenever called.vrrs r__next__z_VariantSignature.__next__Bsr!N)__name__ __module__ __qualname____doc__r r$rr!rrr8s r!rc:eZdZdZd dZdZdZdZdZdZ e Z y) raaA base class for exporting your own Named Services across the Bus. When instantiated, objects of this class attempt to claim the given well-known name on the given bus for the current process. The name is released when the BusName object becomes unreferenced. If a well-known name is requested multiple times, multiple references to the same BusName object will be returned. :Caveats: - Assumes that named services are only ever requested using this class - if you request names from the bus directly, confusion may occur. - Does not handle queueing. Nct|dd|&ddl}|jdtdt }||j vr|j |S|xrt jxsd|xrt jxsdz|xrt jxsdz}|j||}|t jk(rnW|t jk(rnC|t jk(r t||t jk(rnt!d |d |t"j%|} || _|| _| |j |<| S) aSConstructor, which may either return an existing cached object or a new object. :Parameters: `name` : str The well-known name to be advertised `bus` : dbus.Bus A Bus on which this service will be advertised. Omitting this parameter or setting it to None has been deprecated since version 0.82.1. For backwards compatibility, if this is done, the global shared connection to the session bus will be used. `allow_replacement` : bool If True, other processes trying to claim the same well-known name will take precedence over this one. `replace_existing` : bool If True, this process can take over the well-known name from other processes already holding it. `do_not_queue` : bool If True, this service will not be placed in the queue of services waiting for the requested name if another service already holds it. TF)allow_well_known allow_uniqueNrzKOmitting the "bus" parameter to dbus.service.BusName.__init__ is deprecated) stacklevelzrequesting bus name z returned unexpected value )rwarningswarnDeprecationWarningr _bus_names_dbus_bindingsNAME_FLAG_ALLOW_REPLACEMENTNAME_FLAG_REPLACE_EXISTINGNAME_FLAG_DO_NOT_QUEUE request_name REQUEST_NAME_REPLY_PRIMARY_OWNERREQUEST_NAME_REPLY_IN_QUEUEREQUEST_NAME_REPLY_EXISTSr REQUEST_NAME_REPLY_ALREADY_OWNER RuntimeErrorobject__new___bus_name) clsnamebusallow_replacementreplace_existing do_not_queuer/ name_flagsretvalbus_names rr>zBusName.__new__WsT4 $EJ ;  MMH,  <,C 3>> !>>$' ' M>#M#M RQR  K."K"K Pq R  CnCC Hq J  !!$ 3 ^DD D  ~AA A  ~?? ?%d+ + ~FF F X\^def f>>#&  (tr!cyNr)rargskeywordss r__init__zBusName.__init__s r!cN|jj|jyrK)r? release_namer@rs r__del__zBusName.__del__s tzz* r!c|jS)zGet the Bus this Service is on)r?rs rget_buszBusName.get_buss yyr!c|jS)zGet the name of this service)r@rs rget_namezBusName.get_names zzr!cLd|j|jt|fzS)Nz&)r@r?idrs r__repr__zBusName.__repr__s#74::tyyRTUYRZ:[[[r!)NFFF) r%r&r'r(r>rNrQrSrUrX__str__rr!rrrGs-K^  \Gr!rcrd}d}d}|r|jjD]}|sx||jvrjd|j|jvrMd|j|jvr2|j|j|k(r|}|j|}d}nn|}|s||jvsd|j|jvsd|j|jvs|j|j|k(s|j|}d}nonm|jjD]T}|s||jvr|}|s||jvs'd|j|jvsC|j|}d}n|r|j||fS|rt |d|t d|z)zWalks the Python MRO of the given class to find the method to invoke. Returns two methods, the one to call, and the one it inherits from which defines its D-Bus interface name, signature, and attributes. NF_dbus_is_method_dbus_interfaceTz$ is not a valid method of interface z%s is not a valid method) __class____mro____dict__r\r)r method_namedbus_interface parent_methodcandidate_class successfulrAs r_method_lookupres MOJ>>)) C$ s||(C%k)B)K)KK)S\\+-F-O-OO||K0@@NR*-(+ [(A %) &)O  K3<<$?%k)B)K)KK%k)B)K)KKLL-==O!$ [ 9 ! ; B>>)) C# s||(C"%K3<<$?%k)B)K)KK # [ 9 !  ((5}EE (Wbdr)st t()Ck)QR Rr!ct|} |j|d|i|js|j|yy#t$r}tj|J |j |dz}n4#t$r(}t jd||j|d}~wwxYwt jd|||j|d}~wwxYw)N signaturez (guessed)z2Unable to guess signature for arguments %r: %s: %sz8Unable to append %r to message with signature %s: %s: %s) rappend Exceptionlogging basicConfigguess_signature_loggererrorr] get_no_reply send_message) connectionmessager`rgrHreplyes r_method_reply_returnrus  (E  62y2    !& "     !11&9LH   '(. Q@    & 1;; C  s;A C C"A76C7 B(#B##B(('CCc^t|dd}|nOt|dddvrd|jjz}n&d|jd|jj}t j \}}}t |tr|js|j}nZ||ur'djtj|||}n/djtj|j|}t|||}|js|j!|yy)N_dbus_error_namer&)rx__main__zorg.freedesktop.DBus.Python.%szorg.freedesktop.DBus.Python..)getattrr]r%r&sysexc_info isinstancerinclude_tracebackget_dbus_messagejoin tracebackformat_exceptionformat_exception_onlyrrorp) rqrr exceptionrBetevetbcontentsrss r_method_reply_errorrs 90$ 7D  L" -1A A/)2E2E2N2NN B7@6J6JIL_L_LhLhi,,.KBC)]+I4O4O--/ y77955b"cBC 779::9;N;N  $ 1E    !& "r!c*eZdZfdZdZdZxZS) InterfaceTypect|di}||_ix}||jdz|z<|D]j}|jdz|jz}t|dds-||j D](\}} |j |i} | j | *l|jD];} t| dds|j | ji} | | | j<=tt|/|||y)N_dbus_class_tablerzFr\) r{rr&r%items setdefaultupdatevaluesr\superrrN) rArBbasesdct class_tableinterface_tableb base_name interface method_tableour_method_tablefuncr]s rrNzInterfaceType.__init__1sc#6; +EGG+cnns&:T&AB :A s*QZZ7Iq-u51 z2 z( z ) _dbus_args_dbus_in_signaturetupler r_dbus_out_signaturer%zip)rArrLin_sigout_sigreflection_datapairtypes r_reflect_on_methodz InterfaceType._reflect_on_methodKs  " "9T%<%<=>F'(F  # # 8 89G G4 F% \D TW[[ [O \ RD JTQ QO R,,r!c|j}|jrtt|j}n t }d|j z}t ||D] }|d|zz} |dz}|S)Nz z" z )r_dbus_signaturerr rr%r)rArrLsigrrs r_reflect_on_signalz InterfaceType._reflect_on_signalhs|    $"6"678C$%C4 FTN ]D-0UX\0\\O ]),==r!)r%r&r'rNrr __classcell__r]s@rrr0s=4:r!r InterfaceceZdZdZdZdZddZedZedZ edZ dZ dd Z d Z d Zeed d dddZdZeZy)raA base class for exporting your own Objects across the Bus. Just inherit from Object and mark exported methods with the @\ `dbus.service.method` or @\ `dbus.service.signal` decorator. Example:: class Example(dbus.service.object): def __init__(self, object_path): dbus.service.Object.__init__(self, dbus.SessionBus(), path) self._last_input = None @dbus.service.method(interface='com.example.Sample', in_signature='v', out_signature='s') def StringifyVariant(self, var): self.LastInputChanged(var) # emits the signal return str(var) @dbus.service.signal(interface='com.example.Sample', signature='v') def LastInputChanged(self, var): # run just before the signal is actually emitted # just put "pass" if nothing should happen self._last_input = var @dbus.service.method(interface='com.example.Sample', in_signature='', out_signature='v') def GetLastInput(self): return self._last_input FNcR| t|t|tr|}|j}n|||j}d|_d|_g|_tj|_ d|_ ||_ | | td|||j||yyy)aConstructor. Either conn or bus_name is required; object_path is also required. :Parameters: `conn` : dbus.connection.Connection or None The connection on which to export this object. If None, use the Bus associated with the given ``bus_name``. If there is no ``bus_name`` either, the object is not initially available on any Connection. For backwards compatibility, if an instance of dbus.service.BusName is passed as the first parameter, this is equivalent to passing its associated Bus as ``conn``, and passing the BusName itself as ``bus_name``. `object_path` : str or None A D-Bus object path at which to make this Object available immediately. If this is not None, a `conn` or `bus_name` must also be provided. `bus_name` : dbus.service.BusName or None Represents a well-known name claimed by this process. A reference to the BusName object will be held by this Object, preventing the name from being released during this Object's lifetime (unless it's released manually). NFz>%)9 $1H#+x{j/H!)<x01 //"$!/3Z#GHH$ QK77 D??..x8   ( ( *# &  ( ( *saAD+! D+,AD+/D  D+D/D+ DD+DD+ D(%D+'D((D++Ec2tjd||y)Nz5Unregistering exported object %r from some path on %r)rminfo)rrqs rrzObject._unregister_cbs "J 0r!cttsy jj}t ||\}}j di|j }i}|jt|jnd|jr#|j\}} fd||<fd|| <|jrj||j<|jrj||j<|jrj} | } |jD]b} | dus | | dk(rd} nN| ddk(r | j!| ddzs8| t#| dd} t#| t#| ksa| } dt%| } | ||j<|j&rj)||j&<|j*r||j*<|j,r||j,<||g|i|}|jryct/}t#|dk(r|dk(rd}nkt1dzt#|dk(r|f}nKt|t2rn:t1dd |d}n$t|t.rt|t4sn|f}t7g|y#t8$r}t;|Yd}~yd}~wwxYw) Nc"tg|SrK)ru)rHrqrrr`rgs rz$Object._message_cb..s'.s=PQ[]dfo=pr!rr/rz8%s has an empty output signature but did not return Nonez) has multiple output values in signature z but did not return a sequence)r~r get_member get_interfacere get_args_list_dbus_get_args_optionsrr _dbus_async_callbacks_dbus_sender_keyword get_sender_dbus_path_keywordget_path_dbus_rel_path_keywordr startswithlenr _dbus_destination_keywordget_destination_dbus_message_keyword_dbus_connection_keywordrrr rrurir)rrqrrinterface_namecandidate_methodrbrLrMreturn_callbackerror_callbackrrel_pathexpsuffixrHsignature_tuplerr`rgs `` @@rrzObject._message_cbs'#45 h @!,,.K$224N0>t[R`0a - })7((P=+O+OPDH00<%m&G&GH  224A4W4W1.-G)+p(11?F?Q?Q?S;;<//=D=M=M=O99:33'')??2C 1v+3q6>'*H!q6S=$??3q6C<8%)#c!f+,%7F"6{S]:+1!2"&h/AI==>66DKD[D[D]@@A22@G<<=55CM??@&d>T>X>F22 $"' "2'1,~!#'(b')()))Q.$YF!&(3'())566 >F /(8$YF Wk9 Vv V @  GY ? ? @s2D'K ?,K ,(K BK +BK K) K$$K)rxsrrq) in_signature out_signature path_keywordconnection_keywordctj}|d|zz }|j|jjdz|jj z}|j D]\}}|d|zz }|jD]Z}t|ddr||jj|z }/t|dds=||jj|z }\|dz }|j|D] }|d|zz } |d z }|S) ziReturn a string of XML encoding this object's supported interfaces, methods and signals. z rzz r[F_dbus_is_signalz z z ) r3)DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODErr]r&r%rrr{rrlist_exported_child_objects)rrrqr interfacesrBfuncsrs r IntrospectzObject.Introspects' )RR/+==++DNN,E,E,KdnnNeNe,ef '--/ 2MT5 :dC CO  O4!2E:#t~~'H'H'NNOT#4e<#t~~'H'H'NNO  O 1 1O 2::;G >D 6= =O > ;&r!cd}|jtur|jd|jz}d|jj|jj|t |fzS)Nrxz at %sz<%s.%s%s at %#x>)rrr]r&r%rW)rwheres rrXzObject.__repr__se   U *!!-t000E!T^^%>%>#'>>#:#:E#%d8%-- -r!)NNNNN)r%r&r'r(rrrNpropertyrrqrrrrrrr rrXrYrr!rrrsF&+" %*!;6z % % $ $ % %9+v/+b0 l@\ r&<II4-Gr!rc(eZdZdZdZdfd ZxZS)rzaAn object that implements an entire subtree of the object-path tree. :Since: 0.82.0 Tctt| d|_|| t dy| t d|j ||y)aHConstructor. Note that the superclass' ``bus_name`` __init__ argument is not supported here. :Parameters: `conn` : dbus.connection.Connection or None The connection on which to export this object. If this is not None, an `object_path` must also be provided. If None, the object is not initially available on any Connection. `object_path` : str or None A D-Bus object path at which to make this Object available immediately. If this is not None, a `conn` must also be provided. This object will implements all object-paths in the subtree starting at this object-path, except where a more specific object has been added. TNz)If object_path is given, conn is requiredz)If conn is given, object_path is required)rrrNrrr)rrrr]s rrNzFallbackObject.__init__(sW. nd,. <& KLL'  GH H  " "4 5r!r)r%r&r'r(rrNrrs@rrrs &*" 6 6r!r)0__all__ __docformat__r|rjrrcollections.abcr ImportError collectionsr3dbusr r r r rrrdbus.decoratorsrrdbus.exceptionsrrr dbus.lowlevelrrr dbus.proxiesr dbus._compatr getLoggerrmr=rrrerurrrrrrrrr!rrs8 F" %( ---+@@NN# '  N +  rfrj?SD'*':HDHZ +y" 5 YYYv )6V)6u%$%sB?? C  C