Your IP : 3.138.181.100


Current Path : /lib64/python2.7/site-packages/dbus/
Upload File :
Current File : //lib64/python2.7/site-packages/dbus/service.pyc

�
oMTc@s�ddddfZdZddlZddlZddlZddlZddlmZddlZddl	m
Z
mZmZm
Z
mZmZmZdd	lmZmZdd
lmZmZmZddlmZmZmZddlmZdd
lmZej d�Z!de"fd��YZ#de"fd��YZ$d�Z%d�Z&d�Z'de(fd��YZ)e)de"fi�Z*e"�Z+de*fd��YZ,de,fd��YZ-dS(tBusNametObjecttmethodtsignaltrestructuredtexti����N(tSequence(tINTROSPECTABLE_IFACEt
ObjectPatht
SessionBust	SignaturetStructtvalidate_bus_nametvalidate_object_path(RR(t
DBusExceptiontNameExistsExceptiontUnknownMethodException(tErrorMessagetMethodReturnMessagetMethodCallMessage(t
LOCAL_PATH(tis_py2sdbus.servicet_VariantSignaturecBs/eZdZd�Zd�Zer-eZnRS(s�A 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
		cBsVeZdZdeeed�Zd�Zd�Zd�Zd�Z	d�Z
e
ZRS(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}|jdtdd�t�}n||jkrj|j|S|ryt	j
p|d|r�t	jp�dB|r�t	jp�dB}|j
||�}|t	jkr�nX|t	jkr�nF|t	jkr�t|��n(|t	jkrntd	||f��tj|�}	||	_||	_|	|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_uniquei����NsKOmitting the "bus" parameter to dbus.service.BusName.__init__ is deprecatedt
stackleveliis3requesting bus name %s returned unexpected value %s(RtTruetFalsetNonetwarningstwarntDeprecationWarningRt
_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|j�dS(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_bus�scCs|jS(sGet the name of this service(R5(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pytget_name�scCsd|j|jt|�fS(Ns&<dbus.service.BusName %s on %r at %#x>(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	Cs�d}d}t}|r!x~|jjD]�}|r�||jkr�d|j|jkr�d|j|jkr�|j|j|kr�|}|j|}t}Pq�q�|}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|r�td||f��ntd|��dS(s�Walks 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(Rtmethod_nametdbus_interfacet
parent_methodtcandidate_classt
successfulR6((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt_method_lookup�sF
	
	
cGs�t|�}y|jd||�Wn�tk
r�}tj�|dkr�y|j|�d}Wq�tk
r�}tjd||j	|��q�Xntjd|||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	ExceptiontloggingtbasicConfigR#tguess_signaturet_loggerterrorRKtsend_message(t
connectiontmessageRNRTR=treplyte((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt_method_reply_return�s 
	
	c	Cst|dd�}|dk	r!nDt|dd�dkrLd|jj}nd|j|jjf}tj�\}}}t|t�r�|j	r�|j
�}nK||kr�djtj
|||��}ndjt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#eZd�Zd�Zd�ZRS(cCst|di�}||_i}||jd|<xw|D]o}|jd|j}t|dt�r;x@||j�D]+\}}	|j|i�}
|
j|	�qxWq;q;WxK|j�D]=}t|dt�r�|j|j	i�}	||	|j<q�q�Wt
t|�j|||�dS(Nt_dbus_class_tablet.RJ(
ReRvRRR"titemst
setdefaulttupdatetvaluesRJtsuperRuRA(R6R7tbasestdcttclass_tabletinterface_tabletbt	base_namet	interfacetmethod_tabletour_method_tabletfunc((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRA,s	
cCs�|j}|jr*tt|j��}n	t�}|jrNt|j�}ng}d|j}x%t||�D]}|d|7}qqWx|D]}|d|7}q�W|d7}|S(Ns    <method name="%s">
s2      <arg direction="in"  type="%s" name="%s" />
s(      <arg direction="out" type="%s" />
s    </method>
(t
_dbus_argst_dbus_in_signaturettupleR	Rt_dbus_out_signatureRtzip(R6R�R?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    <signal name="%s">
s"      <arg type="%s" name="%s" />
s    </signal>
(R�t_dbus_signatureR�R	RRR�(R6R�R?tsigR�R�((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt_reflect_on_signalcs			

(RRRAR�R�(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRu+s		t	Interfacec
Bs�eZdZeZeZdddd�Zed��Z	ed��Z
ed��Zd�Zddd�Z
d�Zd�Zeed	d
ddd
ddd�d��Zd�ZeZRS(s�A 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|t�r=|}|j�}n*|dkrg|dk	rg|j�}qgnd|_d|_g|_tj	�|_
t|_||_
|dkr�|dk	r�td��n|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(Rtconntobject_pathR>((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRA�s$
					cCsO|jtkr"td|��n)|jdkrDtd|��n|jSdS(s�The 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(R�t_MANYtAttributeErrorR#(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt__dbus_object_path__�s
cCsO|jtkr"td|��n)|jdkrDtd|��n|jSdS(s�The 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(R�R�R�R#(R((s2/usr/lib64/python2.7/site-packages/dbus/service.pyR]�s
cCs
t|j�S(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|tkrtdt��n|jj�z3|jdk	rs|j|k	rs|jrstd||jf��n|jdk	r�|jr�|j|kr�td||jf��n|j	||j
|j|j�|jdkr�||_n|j|k	rt
|_n|jdkr'||_n|j|krBt
|_n|jj|||jf�Wd|jj�XdS(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
ValueErrorR�tacquireR�R#tSUPPORTS_MULTIPLE_CONNECTIONSR�tSUPPORTS_MULTIPLE_OBJECT_PATHSt_register_object_patht_message_cbt_unregister_cbR�R�R�RUtrelease(RR]tpath((s2/usr/lib64/python2.7/site-packages/dbus/service.pyR�s8




 cCsz|jj�zX|jdks.|jdkrAtd|��n|dk	sY|dk	r�g}xn|jD]N}|dks�|d|kri|dks�|d|kri|j|�qiqiWn|j}g|_|s�td|||f��nxo|D]g}y|dj|d�Wntk
r+nX|jr�y|jj	|�Wq`t
k
r\q`Xq�q�WWd|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(R�R�R�R#R�tLookupErrorR�RUt_unregister_object_pathtremoveR�R�(RR]R�tdroppedtlocation((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.pyR��s	csyt�t�sdSy<�j���j�}t|�|�\}}�j|j�}i}|jdk	rt	|j��nd�|j
r�|j
\}}	����fd�||<��fd�||	<n|jr��j�||j<n|j
r�j�||j
<n|jr��j�}
|
}x�|jD]�}|d�kr5|
|dkred}Pn|ddkr{q5n|
j|dd�r�|
t|d�}
t|
�t|�kr�|
}q�q�q5q5Wt|�}|||j<n|jr�j�||j<n|jr%�||j<n|jr>�||j<n||||�}|j
r]dS�dk	r�t��}t|�dkr�|dkr�d}q�td���q8t|�dkr�|f}q8t|t�r�q8td��f��n@|dkr
d	}n+t|t�r/t|t�r/n	|f}t����|�Wn#tk
rt}t��|�nXdS(
Ncst����|�S(N(Ra(R=(R]R^RNRT(s2/usr/lib64/python2.7/site-packages/dbus/service.pyt<lambda>�scst��|�S(N(Rt(Ro(R]R^(s2/usr/lib64/python2.7/site-packages/dbus/service.pyR��siit/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_optionsR�R#R	t_dbus_async_callbackst_dbus_sender_keywordt
get_sendert_dbus_path_keywordtget_patht_dbus_rel_path_keywordR�t
startswithtlenRt_dbus_destination_keywordtget_destinationt_dbus_message_keywordt_dbus_connection_keywordR�R�RR
RaRVRt(RR]R^tinterface_nametcandidate_methodRPR?R@treturn_callbackterror_callbackR�trel_pathtexptsuffixR=tsignature_tupleRo((R]R^RNRTs2/usr/lib64/python2.7/site-packages/dbus/service.pyR��s�									
		tin_signatureRct
out_signaturetstpath_keywordR�tconnection_keywordR]cCstj}|d|7}|j|jjd|jj}x�|j�D]�\}}|d|7}xj|j�D]\}t|dt	�r�||jj
|�7}qlt|dt	�rl||jj|�7}qlqlW|d7}qEWx%|j|�D]}|d|7}q�W|d7}|S(	siReturn a string of XML encoding this object's supported interfaces,
        methods and signals.
        s<node name="%s">
Rws  <interface name="%s">
RIt_dbus_is_signals  </interface>
s  <node name="%s"/>
s</node>
(
R(t)DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODERvRKRRRxR{ReR"R�R�tlist_exported_child_objects(RR�R]R�t
interfacesR7tfuncsR�((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt
Introspect�s	!
cCsZd}|jtk	r4|jdk	r4d|j}nd|jj|jj|t|�fS(NRcs at %ss<%s.%s%s at %#x>(R�R�R#RKRRRF(Rtwhere((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRGsN(RRRR"R�R�R#RAtpropertyR�R]R�R�R�R�R�RRR�RGRH(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRs=	;1		n	tFallbackObjectcBs#eZdZeZddd�ZRS(saAn object that implements an entire subtree of the object-path
    tree.

    :Since: 0.82.0
    cCsutt|�j�t|_|dkrF|dk	rqtd��qqn+|dkratd��n|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|R�RAR!R�R#R�R�(RR�R�((s2/usr/lib64/python2.7/site-packages/dbus/service.pyRA#s	N(RRRR!R�R#RA(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyR�s(.t__all__t
__docformat__RfRWR�RltcollectionsRR(tdbusRRRR	R
RRtdbus.decoratorsRRtdbus.exceptionsR
RRt
dbus.lowlevelRRRtdbus.proxiesRtdbus._compatRt	getLoggerRZR2RRRSRaRtR�RuR�R�RR�(((s2/usr/lib64/python2.7/site-packages/dbus/service.pyt<module>s24u	B		M	��