コード例 #1
0
ファイル: core.py プロジェクト: sauloal/linuxscripts
    def set_link_details(self, **kwargs): # AzureusLink
        """
        Sets the details of where the Azureus server to connect to is located.

        @rtype: None
        @keyword host: Host name of the machine to connect to (default is
            C{127.0.0.1}).
        @keyword port: Server port that Azureus is accepting XML/HTTP
            connections on (default is C{6884}).
        @keyword secure: Set to a true value if the Azureus is only
            accepting secure connections (default is C{False}).
        @keyword user: For authenticated connections - the user name to
            connect as (default is to use no authentication).
        @keyword password: For authenticated connections - the password to
            connect with (default is to use no authentication).
        """

        # Smart use of handle_kwargs, I think. :)
        from dopal.utils import handle_kwargs
        kwargs = handle_kwargs(kwargs, **self.link_data)

        #for key, value in kwargs.items():
        #    if key not in self.link_data:
        #        raise TypeError, "invalid keyword argument: %s" % key
        self.link_data.update(kwargs)
コード例 #2
0
    def set_link_details(self, **kwargs):  # AzureusLink
        """
        Sets the details of where the Azureus server to connect to is located.

        @rtype: None
        @keyword host: Host name of the machine to connect to (default is
            C{127.0.0.1}).
        @keyword port: Server port that Azureus is accepting XML/HTTP
            connections on (default is C{6884}).
        @keyword secure: Set to a true value if the Azureus is only
            accepting secure connections (default is C{False}).
        @keyword user: For authenticated connections - the user name to
            connect as (default is to use no authentication).
        @keyword password: For authenticated connections - the password to
            connect with (default is to use no authentication).
        """

        # Smart use of handle_kwargs, I think. :)
        from dopal.utils import handle_kwargs
        kwargs = handle_kwargs(kwargs, **self.link_data)

        #for key, value in kwargs.items():
        #    if key not in self.link_data:
        #        raise TypeError, "invalid keyword argument: %s" % key
        self.link_data.update(kwargs)
コード例 #3
0
    def __init__(self, *args, **kwargs):

        if len(args) + len(kwargs) > 3:
            raise ValueError, "DopalError.__init__ takes at most 3 arguments - %s positional argument(s) given, %s keyword argument(s) given" % (
                len(args), len(kwargs))

        # Filters out invalid keywords.
        from dopal.utils import handle_kwargs

        handle_kwargs(kwargs, error=None, obj=None, text=None)

        error = obj = text = None
        has_error = has_object = has_text = False

        import types

        for kwname, kwvalue in kwargs.items():

            if kwname == 'error':
                if not isinstance(kwvalue, Exception):
                    msg = "'error' keyword argument is not Exception: %r"
                    raise TypeError, msg % (kwvalue, )
                has_error = True
                error = kwvalue

            elif kwname == 'text':
                if not isinstance(kwvalue, types.StringTypes):
                    msg = "'text' keyword argument is not a String type: %r"
                    raise TypeError, msg % (kwvalue, )
                has_text = True
                text = kwvalue

            else:  # kwname == 'obj'
                has_object = True
                obj = kwvalue

        import types

        for arg in args:
            if isinstance(arg, Exception) and not has_error:
                has_error = True
                error = arg
            elif isinstance(arg, types.StringTypes) and not has_text:
                has_text = True
                text = arg
            else:
                if has_object:
                    msg = "could not determine Dopal argument type for %r"
                    raise TypeError, msg % (arg, )
                has_object = True
                obj = arg

        dopal_arg_tuple = args
        if kwargs:
            dopal_arg_tuple += tuple(kwargs.values())

        dopal_arg_dict = {}
        if has_error:
            dopal_arg_dict['error'] = error
        if has_object:
            dopal_arg_dict['object'] = obj
        if has_text:
            dopal_arg_dict['text'] = text

        self.dopal_arg_tuple = dopal_arg_tuple
        self.dopal_arg_dict = dopal_arg_dict
        self.error = error
        self.obj = obj
        self.text = text
        self.has_object = has_object
        self.has_error = has_error
        self.has_text = has_text

        # super(DopalError, self).__init__(dopal_arg_tuple)
        Exception.__init__(self, *dopal_arg_tuple)
コード例 #4
0
def _invoke_remote_method(self, *args, **kwargs):
    from dopal.utils import handle_kwargs

    kwargs = handle_kwargs(kwargs, result_type=None)
    return self.invoke_object_method(__funcname__, args, **kwargs)
コード例 #5
0
ファイル: objects.py プロジェクト: Stevie-Bs/repository.xvbmc
def _invoke_remote_method(self, *args, **kwargs):
    from dopal.utils import handle_kwargs

    kwargs = handle_kwargs(kwargs, result_type=None)
    return self.invoke_object_method(__funcname__, args, **kwargs)