def generate(methods):
    clientSkel = ClientSkel.generate(methods)

    class ClientXMLRPC(clientSkel):

        def __init__(self, url, port=80, uri='/'):
            clientSkel.__init__(self,xmlrpclib.Server('http://'+url+':'+str(port)+uri, allow_none = True))

    # Adding properly the testing method to check availability
    if isinstance(methods,dict):
        all_methods = methods.keys()
    else:
        all_methods = list(methods[:])
    all_methods.append('test_me')

    # Generating stubs dinamically
    for method_name in all_methods:
        # Each method can have many stubs (with different prefixes)
        for stub in stubs:
            func = stub(method_name)
            # Setting docstring
            func.__doc__ = (func.__doc__ if func.__doc__ is not None else '').replace('METHOD_NAME', method_name)
            if isinstance(all_methods, dict):
                func.__doc__ = (func.__doc__ if func.__doc__ is not None else '').replace('DOCUMENTATION', all_methods[method_name])
            # Taking "prefix_" from "_prefix_stub"
            stub_prefix = stub.func_name[len('_generate_'):]
            stub_prefix = stub_prefix[:stub_prefix.rfind('stub')]
            func_name = stub_prefix + method_name
            func.func_name = func_name
            setattr(ClientXMLRPC, func_name, func)

    return ClientXMLRPC
def generate(methods):
    clientSkel = ClientSkel.generate(methods)

    class ClientDirect(clientSkel):
        def __init__(self,server):
            clientSkel.__init__(self,server)

    # Adding properly the testing method to check availability
    if isinstance(methods,dict):
        all_methods = methods.keys()
    else:
        all_methods = list(methods[:])
    all_methods.append('test_me')

    # Generating stubs dinamically
    for method_name in all_methods:

        # Each method can have many stubs (with different prefixes)
        for stub in stubs:
            func = stub(method_name)
            # Setting docstring
            func.__doc__ = (func.__doc__ if func.__doc__ is not None else '').replace('METHOD_NAME', method_name)
            if isinstance(all_methods, dict):
                func.__doc__ = (func.__doc__ if func.__doc__ is not None else '').replace('DOCUMENTATION', all_methods[method_name])
            # Taking "prefix_" from "_prefix_stub"
            stub_prefix = stub.func_name[len('_generate_'):]
            stub_prefix = stub_prefix[:stub_prefix.rfind('stub')]
            func_name = stub_prefix + method_name
            func.func_name = func_name
            setattr(ClientDirect, func_name, func)

    return ClientDirect
Beispiel #3
0
def generate(methods):
    clientSkel = ClientSkel.generate(methods)

    class ClientDirect(clientSkel):
        def __init__(self, server):
            clientSkel.__init__(self, server)

    # Adding properly the testing method to check availability
    if isinstance(methods, dict):
        all_methods = methods.keys()
    else:
        all_methods = list(methods[:])
    all_methods.append("test_me")

    # Generating stubs dinamically
    for method_name in all_methods:

        # Each method can have many stubs (with different prefixes)
        for stub in stubs:
            func = stub(method_name)
            # Setting docstring
            func.__doc__ = (func.__doc__ if func.__doc__ is not None else "").replace("METHOD_NAME", method_name)
            if isinstance(all_methods, dict):
                func.__doc__ = (func.__doc__ if func.__doc__ is not None else "").replace(
                    "DOCUMENTATION", all_methods[method_name]
                )
            # Taking "prefix_" from "_prefix_stub"
            stub_prefix = stub.func_name[len("_generate_") :]
            stub_prefix = stub_prefix[: stub_prefix.rfind("stub")]
            func_name = stub_prefix + method_name
            func.func_name = func_name
            setattr(ClientDirect, func_name, func)

    return ClientDirect
def generate(methods):
    clientSkel = ClientSkel.generate(methods)

    class ClientInternetSocket(clientSkel):
        def __init__(self, hostname, port):
            clientSkel.__init__(self, InternetSocketManager(hostname=hostname, port=port))

    return ClientBaseSocket.generate_base(methods, ClientInternetSocket)
Beispiel #5
0
    def generate(methods):
        clientSkel = ClientSkel.generate(methods)

        class ClientUnixSocket(clientSkel):
            def __init__(self, path):
                clientSkel.__init__(self, UnixSocketManager(path=path))

        return ClientBaseSocket.generate_base(methods, ClientUnixSocket)
def generate(methods):
    clientSkel = ClientSkel.generate(methods)

    class ClientInternetSocket(clientSkel):
        def __init__(self, hostname, port):
            clientSkel.__init__(
                self, InternetSocketManager(hostname=hostname, port=port))

    return ClientBaseSocket.generate_base(methods, ClientInternetSocket)
Beispiel #7
0
def generate(methods):
    clientSkel = ClientSkel.generate(methods)

    class ClientSOAP(clientSkel):
        def __init__(self, url, port=80):
            if SOAPPY_AVAILABLE:
                proxy = SOAPpy.SOAPProxy('http://' + url + ':' + str(port))
            else:
                proxy = None
                msg = "The optional library 'SOAPpy' is not available. The communications between different servers will not work through SOAP. Since the client is being instanciated, there will probably be uncommon errors."
                print >> sys.stderr, msg
                log.log(self, log.level.Error, msg)

            clientSkel.__init__(self, proxy)

    # Adding properly the testing method to check availability
    if isinstance(methods, dict):
        all_methods = methods.keys()
    else:
        all_methods = list(methods[:])
    all_methods.append('test_me')

    # Generating stubs dinamically
    for method_name in all_methods:

        # Each method can have many stubs (with different prefixes)
        for stub in stubs:
            func = stub(method_name)
            # Setting docstring
            func.__doc__ = (func.__doc__ if func.__doc__ is not None else
                            '').replace('METHOD_NAME', method_name)
            if isinstance(all_methods, dict):
                func.__doc__ = (func.__doc__ if func.__doc__ is not None else
                                '').replace('DOCUMENTATION',
                                            all_methods[method_name])
            # Taking "prefix_" from "_prefix_stub"
            stub_prefix = stub.func_name[len('_generate_'):]
            stub_prefix = stub_prefix[:stub_prefix.rfind('stub')]
            func_name = stub_prefix + method_name
            func.func_name = func_name
            setattr(ClientSOAP, func_name, func)

    return ClientSOAP
Beispiel #8
0
def generate(methods):
    clientSkel = ClientSkel.generate(methods)

    class ClientSOAP(clientSkel):
        def __init__(self, url, port=80):
            if SOAPPY_AVAILABLE:
                proxy = SOAPpy.SOAPProxy("http://" + url + ":" + str(port))
            else:
                proxy = None
                msg = "The optional library 'SOAPpy' is not available. The communications between different servers will not work through SOAP. Since the client is being instanciated, there will probably be uncommon errors."
                print >>sys.stderr, msg
                log.log(self, log.level.Error, msg)

            clientSkel.__init__(self, proxy)

    # Adding properly the testing method to check availability
    if isinstance(methods, dict):
        all_methods = methods.keys()
    else:
        all_methods = list(methods[:])
    all_methods.append("test_me")

    # Generating stubs dinamically
    for method_name in all_methods:

        # Each method can have many stubs (with different prefixes)
        for stub in stubs:
            func = stub(method_name)
            # Setting docstring
            func.__doc__ = (func.__doc__ if func.__doc__ is not None else "").replace("METHOD_NAME", method_name)
            if isinstance(all_methods, dict):
                func.__doc__ = (func.__doc__ if func.__doc__ is not None else "").replace(
                    "DOCUMENTATION", all_methods[method_name]
                )
            # Taking "prefix_" from "_prefix_stub"
            stub_prefix = stub.func_name[len("_generate_") :]
            stub_prefix = stub_prefix[: stub_prefix.rfind("stub")]
            func_name = stub_prefix + method_name
            func.func_name = func_name
            setattr(ClientSOAP, func_name, func)

    return ClientSOAP