Ejemplo n.º 1
0
        def setUp(self):
            self.rpcserver = rpc.rpcserver(PORT)
            self.rpcserver.add_handler(
                'SDAPlotter', lambda plotter_method_name, *args:
                (plotter_method_name, args))
            _start_new_thread(self.rpcserver.serve_forever)

            self.plot = plot.plotter()
            plot.setremoteport(PORT)
Ejemplo n.º 2
0
    def testExceptionOnHandlerFlattening(self):
        rpcserver = rpc.rpcserver(0)
        rpcserver.add_handler("flaterror", lambda o: object())

        _start_new_thread(rpcserver.serve_forever)
        try:
            rpcclient = rpc.rpcclient(rpcserver.port)
            self.assertRaises(Exception, rpcclient.flaterror, ("Hello",))
        finally:
            rpcserver.shutdown()
            rpcserver.close()
Ejemplo n.º 3
0
    def testSingleIntegerArg(self):
        rpcserver = rpc.rpcserver(0)
        rpcserver.add_handler("echo", lambda o: o)

        _start_new_thread(rpcserver.serve_forever)
        try:
            rpcclient = rpc.rpcclient(rpcserver.port)
            self.assertRaises(Exception, rpcclient.flaterror, (18,))
        finally:
            rpcserver.shutdown()
            rpcserver.close()
Ejemplo n.º 4
0
    def testMultipleHandlers(self):
        rpcserver = rpc.rpcserver(0)
        rpcserver.add_handler("cat", lambda s1, s2: s1 + s2)
        rpcserver.add_handler("len", lambda s1, s2: len(s1 + s2))

        _start_new_thread(rpcserver.serve_forever)
        try:
            rpcclient = rpc.rpcclient(rpcserver.port)
            result = rpcclient.cat("Hello, ", "World!")
            self.assertEqual("Hello, World!", result)
            result = rpcclient.len("Hello, ", "World!")
            self.assertEqual(len("Hello, World!"), result)
        finally:
            rpcserver.shutdown()
            rpcserver.close()
 def setUp(self):
     self.rpcserver = rpc.rpcserver(0)
     self.rpcserver.add_handler("cat", lambda s1, s2: s1 + s2)
     _start_new_thread(self.rpcserver.serve_forever)
     self.rpcclient = rpc.rpcclient(self.rpcserver.port)