コード例 #1
0
    def _test_encode(self, valuesWithEncoders):
        values, encoders = zip(*valuesWithEncoders)
        inKwargs = dict(zip(string.ascii_lowercase, values))
        boxKwargs = ampencode.toBoxKwargs(inKwargs)
        self.assertEqual(len(inKwargs), len(boxKwargs))

        for key, encoder in zip(string.ascii_lowercase, encoders):
            self.assertEqual(boxKwargs[key], encoder.toString(inKwargs[key]))
コード例 #2
0
ファイル: test_ampencode.py プロジェクト: lvh/amphibian
    def _test_encode(self, valuesWithEncoders):
        values, encoders = zip(*valuesWithEncoders)
        inKwargs = dict(zip(string.ascii_lowercase, values))
        boxKwargs = ampencode.toBoxKwargs(inKwargs)
        self.assertEqual(len(inKwargs), len(boxKwargs))

        for key, encoder in zip(string.ascii_lowercase, encoders):
            self.assertEqual(boxKwargs[key], encoder.toString(inKwargs[key]))
コード例 #3
0
ファイル: jsonrpc.py プロジェクト: lvh/amphibian
def handleRequest(string, client, write):
    """
    Handles an incoming request.
    """
    identifier, requiresAnswer = None, False

    try:
        request = _parseRequest(string)
        method, identifier, kwargs = _extractDetails(request)
        boxKwargs = ampencode.toBoxKwargs(kwargs)
        requiresAnswer = identifier is not None
        d = client.callRemoteString(method, requiresAnswer, **boxKwargs)
    except Exception as e:
        d = defer.fail(e)

    if requiresAnswer:
        d.addBoth(encode, identifier)
        d.addCallback(write)
    
    return d
コード例 #4
0
ファイル: jsonrpc.py プロジェクト: vaizguy/amphibian
def handleRequest(string, client, write):
    """
    Handles an incoming request.
    """
    identifier, requiresAnswer = None, False

    try:
        request = _parseRequest(string)
        method, identifier, kwargs = _extractDetails(request)
        boxKwargs = ampencode.toBoxKwargs(kwargs)
        requiresAnswer = identifier is not None
        d = client.callRemoteString(method, requiresAnswer, **boxKwargs)
    except Exception as e:
        d = defer.fail(e)

    if requiresAnswer:
        d.addBoth(encode, identifier)
        d.addCallback(write)

    return d