毖Sc@sddddfZdZddlZddlZddlZddlZddlmZddlZddl m Z m Z m Z m Z mZmZmZdd lmZmZdd lmZmZmZdd lmZmZmZdd lmZdd lmZej dZ!de"fdYZ#de"fdYZ$dZ%dZ&dZ'de(fdYZ)e)de"fiZ*e"Z+de*fdYZ,de,fdYZ-dS(tBusNametObjecttmethodtsignaltrestructuredtextiN(tSequence(tINTROSPECTABLE_IFACEt ObjectPatht SessionBust SignaturetStructtvalidate_bus_nametvalidate_object_path(RR(t DBusExceptiontNameExistsExceptiontUnknownMethodException(t ErrorMessagetMethodReturnMessagetMethodCallMessage(t LOCAL_PATH(tis_py2s dbus.servicet_VariantSignaturecBs/eZdZdZdZer-eZnRS(sA fake method signature which, when iterated, yields an endless stream of 'v' characters representing variants (handy with zip()). It has no string representation. cCs|S(s Return self.((tself((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt__iter__8scCsdS(sReturn 'v' whenever called.tv((R((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt__next__<s(t__name__t __module__t__doc__RRRtnext(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyR2s   cBsVeZdZdeeedZdZdZdZdZ dZ e Z RS(s^A 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. c CsSt|dtdt|dkrPddl}|jdtddt}n||jkrj|j|S|ryt j p|d|rt j pdB|rt j pdB}|j ||}|t jkrnX|t jkrnF|t jkrt|n(|t jkr ntd ||ftj|} || _|| _| |j|<| S( sSConstructor, 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. tallow_well_knownt allow_uniqueiNsKOmitting the "bus" parameter to dbus.service.BusName.__init__ is deprecatedt stackleveliis3requesting bus name %s returned unexpected value %s(R tTruetFalsetNonetwarningstwarntDeprecationWarningRt _bus_namest_dbus_bindingstNAME_FLAG_ALLOW_REPLACEMENTtNAME_FLAG_REPLACE_EXISTINGtNAME_FLAG_DO_NOT_QUEUEt request_namet REQUEST_NAME_REPLY_PRIMARY_OWNERtREQUEST_NAME_REPLY_IN_QUEUEtREQUEST_NAME_REPLY_EXISTSRt REQUEST_NAME_REPLY_ALREADY_OWNERt RuntimeErrortobjectt__new__t_bust_name( tclstnametbustallow_replacementtreplace_existingt do_not_queueR$t name_flagstretvaltbus_name((s2/usr/lib64/python2.7/site-packages/dbus/service.pyR3Ts2      %   cOsdS(N((Rtargstkeywords((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt__init__scCs|jj|jdS(N(R4t release_nameR5(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt__del__scCs|jS(sGet the Bus this Service is on(R4(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pytget_busscCs|jS(sGet the name of this service(R5(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pytget_namescCsd|j|jt|fS(Ns&(R5R4tid(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt__repr__sN( RRRR#R"R3RARCRDRERGt__str__(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRDsO     c Csd}d}t}|r!x~|jjD]}| r||jkrd|j|jkrd|j|jkr|j|j|kr|}|j|}t}Pqq|}n|r%||jkr%d|j|jkr%d|j|jkr%|j|j|kr%|j|}t}Pq%q%Wnxxu|jjD]g}| rS||jkrS|}n|r.||jkr.d|j|jkr.|j|}t}Pq.q.W|r|j||fS|rtd||fntd|dS(sWalks 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. t_dbus_is_methodt_dbus_interfaces(%s is not a valid method of interface %ss%s is not a valid methodN(R#R"t __class__t__mro__t__dict__RJR!R(Rt method_nametdbus_interfacet parent_methodtcandidate_classt successfulR6((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt_method_lookupsF      cGst|}y|jd||Wntk r}tj|dkry|j|d}Wqtk r}tjd||j |qXntjd|||j |nX|j |dS(Nt signatures (guessed)s2Unable to guess signature for arguments %r: %s: %ss8Unable to append %r to message with signature %s: %s: %s( Rtappendt Exceptiontloggingt basicConfigR#tguess_signaturet_loggerterrorRKt send_message(t connectiontmessageRNRTR=treplyte((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt_method_reply_returns       c Cst|dd}|dk r!nDt|dddkrLd|jj}nd|j|jjf}tj\}}}t|tr|j r|j }nK||krdj t j |||}ndj t j|j|}t|||}|j|dS(Nt_dbus_error_nameRtt__main__sorg.freedesktop.DBus.Python.%ss!org.freedesktop.DBus.Python.%s.%s(Rcs__main__(tgetattrR#RKRRtsystexc_infot isinstanceR tinclude_tracebacktget_dbus_messagetjoint tracebacktformat_exceptiontformat_exception_onlyRR\( R]R^t exceptionR7tettevtetbtcontentsR_((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt_method_reply_errors  ! t InterfaceTypecBs#eZdZdZdZRS(c Cst|di}||_i}||jd| s2 s( s (t _dbus_argst_dbus_in_signaturettupleR Rt_dbus_out_signatureRtzip(R6RR?tin_sigtout_sigtreflection_datatpairttype((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt_reflect_on_methodFs       cCsv|j}|jr*tt|j}n t}d|j}x%t||D]}|d|}qPW|d}|S(Ns s" s (Rt_dbus_signatureRR RRR(R6RR?tsigRR((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt_reflect_on_signalcs     (RRRARR(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRu+s  t Interfacec BseZdZeZeZddddZedZ edZ edZ dZ dddZ dZdZeed d d d d ddddZdZeZRS(sA 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 cCs|dk rt|nt|tr=|}|j}n*|dkrg|dk rg|j}qgnd|_d|_g|_tj |_ t |_ ||_ |dkr|dk rtdn|dk r|dk r|j||ndS(sConstructor. 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). s<If object_path is given, either conn or bus_name is requiredN(R#R RhRRDt _object_patht _connectiont _locationst threadingtLockt_locations_lockR"t _fallbackR5t TypeErrortadd_to_connection(Rtconnt object_pathR>((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRAs$         cCsO|jtkr"td|n)|jdkrDtd|n|jSdS(sThe object-path at which this object is available. Access raises AttributeError if there is no object path, or more than one object path. Changed in 0.82.0: AttributeError can be raised. sEObject %r has more than one object path: use Object.locations insteads Object %r has no object path yetN(Rt_MANYtAttributeErrorR#(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt__dbus_object_path__s  cCsO|jtkr"td|n)|jdkrDtd|n|jSdS(sThe Connection on which this object is available. Access raises AttributeError if there is no Connection, or more than one Connection. Changed in 0.82.0: AttributeError can be raised. sFObject %r is on more than one Connection: use Object.locations insteadsObject %r has no Connection yetN(RRRR#(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pyR]s  cCs t|jS(seAn iterable over tuples representing locations at which this object is available. Each tuple has at least two items, but may have more in future versions of dbus-python, so do not rely on their exact length. The first two items are the dbus.connection.Connection and the object path. :Since: 0.82.0 (titerR(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt locationss c Cst|tkrtdtn|jjz3|jdk rs|j|k rs|j rstd||jfn|jdk r|j r|j|krtd||jfn|j ||j |j |j |jdkr||_n|j|k r t |_n|jdkr'||_n|j|krBt |_n|jj|||j fWd|jjXdS(sNMake this object accessible via the given D-Bus connection and object path. :Parameters: `connection` : dbus.connection.Connection Export the object on this connection. If the class attribute SUPPORTS_MULTIPLE_CONNECTIONS is False (default), this object can only be made available on one connection; if the class attribute is set True by a subclass, the object can be made available on more than one connection. `path` : dbus.ObjectPath or other str Place the object at this object path. If the class attribute SUPPORTS_MULTIPLE_OBJECT_PATHS is False (default), this object can only be made available at one object path; if the class attribute is set True by a subclass, the object can be made available with more than one object path. :Raises ValueError: if the object's class attributes do not allow the object to be exported in the desired way. :Since: 0.82.0 s3Objects may not be exported on the reserved path %ss'%r is already exported on connection %rs(%r is already exported at object path %sN(Rt ValueErrorRtacquireRR#tSUPPORTS_MULTIPLE_CONNECTIONSRtSUPPORTS_MULTIPLE_OBJECT_PATHSt_register_object_patht _message_cbt_unregister_cbRRRRUtrelease(RR]tpath((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRs8           cCsz|jjzX|jdks.|jdkrAtd|n|dk sY|dk rg}xn|jD]N}|dks|d|kri|dks|d|kri|j|qiqiWn|j}g|_|std|||fnxo|D]g}y|dj|dWntk r+nX|jry|jj |Wq`t k r\q`XqqWWd|jj XdS(sMake this object inaccessible via the given D-Bus connection and object path. If no connection or path is specified, the object ceases to be accessible via any connection or path. :Parameters: `connection` : dbus.connection.Connection or None Only remove the object from this Connection. If None, remove from all Connections on which it's exported. `path` : dbus.ObjectPath or other str, or None Only remove the object from this object path. If None, remove from all object paths. :Raises LookupError: if the object was not exported on the requested connection or path, or (if both are None) was not exported at all. :Since: 0.81.1 s%r is not exportediis1%r is not exported at a location matching (%r,%r)N( RRRR#Rt LookupErrorRRUt_unregister_object_pathtremoveRR(RR]Rtdroppedtlocation((s2/usr/lib64/python2.7/site-packages/dbus/service.pytremove_from_connectionPs4       cCstjd||dS(Ns5Unregistering exported object %r from some path on %r(RZtinfo(RR]((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRs csyttsdSy<jj}t||\}}j|j}i}|jdk rt |jnd|j r|j \}} fd||<fd|| ||jscst|S(N(Rt(Ro(R]R^(s2/usr/lib64/python2.7/site-packages/dbus/service.pyRsiit/s8%s has an empty output signature but did not return NonesK%s has multiple output values in signature %s but did not return a sequence(((RhRt get_membert get_interfaceRSt get_args_listt_dbus_get_args_optionsRR#R t_dbus_async_callbackst_dbus_sender_keywordt get_sendert_dbus_path_keywordtget_patht_dbus_rel_path_keywordRt startswithtlenRt_dbus_destination_keywordtget_destinationt_dbus_message_keywordt_dbus_connection_keywordRRRR RaRVRt(RR]R^tinterface_nametcandidate_methodRPR?R@treturn_callbackterror_callbackRtrel_pathtexptsuffixR=tsignature_tupleRo((R]R^RNRTs2/usr/lib64/python2.7/site-packages/dbus/service.pyRs                     t in_signatureRct out_signaturetst path_keywordRtconnection_keywordR]cCstj}|d|7}|j|jjd|jj}x|jD]\}}|d|7}xj|jD]\}t|dt r||jj |7}qlt|dt rl||jj |7}qlqlW|d7}qEWx%|j |D]}|d|7}qW|d7}|S( siReturn a string of XML encoding this object's supported interfaces, methods and signals. s Rws RIt_dbus_is_signals s s ( R(t)DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODERvRKRRRxR{ReR"RRtlist_exported_child_objects(RRR]Rt interfacesR7tfuncsR((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt Introspects ! cCsZd}|jtk r4|jdk r4d|j}nd|jj|jj|t|fS(NRcs at %ss<%s.%s%s at %#x>(RRR#RKRRRF(Rtwhere((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRGs  N(RRRR"RRR#RAtpropertyRR]RRRRRRRRRGRH(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRs= ;1  n tFallbackObjectcBs#eZdZeZdddZRS(saAn object that implements an entire subtree of the object-path tree. :Since: 0.82.0 cCsutt|jt|_|dkrF|dk rqtdqqn+|dkratdn|j||dS(sHConstructor. 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. s)If object_path is given, conn is requireds)If conn is given, object_path is requiredN(R|RRAR!RR#RR(RRR((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRA#s    N(RRRR!RR#RA(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRs(.t__all__t __docformat__RfRWRRlt collectionsRR(tdbusRRRR R R R tdbus.decoratorsRRtdbus.exceptionsR RRt dbus.lowlevelRRRt dbus.proxiesRt dbus._compatRt getLoggerRZR2RRRSRaRtRRuRRRR(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyts2     4u B  M