示例#1
0
    def callRemote(self,
                   objectPath,
                   methodName,
                   interface=None,
                   destination=None,
                   signature=None,
                   body=None,
                   expectReply=True,
                   autoStart=True,
                   timeout=None,
                   returnSignature=_NO_CHECK_RETURN):
        """
        Calls a method on a remote DBus object and returns a deferred to the
        result.

        @type objectPath: C{string}
        @param objectPath: Path of the remote object

        @type methodName: C{string}
        @param methodName: Name of the method to call

        @type interface: None or C{string}
        @param interface: If specified, this specifies the interface containing
            the desired method

        @type destination: None or C{string}
        @param destination: If specified, this specifies the bus name
        containing the remote object

        @type signature: None or C{string}
        @param signature: If specified, this specifies the DBus signature of
            the body of the DBus MethodCall message. This string must be a
            valid Signature string as defined by the DBus specification. If
            arguments are supplied to the method call, this parameter must be
            provided.

        @type body: C{list}
        @param body: A C{list} of Python objects to encode. The list content
            must match the content of the signature parameter

        @type expectReply: C{bool}
        @param expectReply: If True (defaults to True) the returned deferred
            will be called back with the eventual result of the remote call. If
            False, the deferred will be immediately called back with None.

        @type autoStart: C{bool}
        @param autoStart: If True (defaults to True) DBus will attempt to
            automatically start a service to handle the method call if a
            service matching the target object is registered but not yet
            started.

        @type timeout: None or C{float}
        @param timeout: If specified and the remote call does not return a
            value before the timeout expires, the returned Deferred will be
            errbacked with a L{error.TimeOut} instance.

        @type returnSignature: C{string}
        @param returnSignature: If specified, the return values will be
            validated against the signature string. If the returned values do
            not mactch, the returned Deferred witl be errbacked with a
            L{error.RemoteError} instance.

        @rtype: L{twisted.internet.defer.Deferred}
        @returns: a Deferred to the result. If expectReply is False, the
             deferred will be immediately called back with None.
        """

        try:
            mcall = message.MethodCallMessage(
                objectPath,
                methodName,
                interface=interface,
                destination=destination,
                signature=signature,
                body=body,
                expectReply=expectReply,
                autoStart=autoStart,
                oobFDs=self._toBeSentFDs,
            )

            d = self.callRemoteMessage(mcall, timeout)

            d.addCallback(self._cbCvtReply, returnSignature)

            return d
        except Exception:
            return defer.fail()
示例#2
0
 def c():
     message.MethodCallMessage('/org/freedesktop/DBus/Local', 'foo')