Mark Slee | c967656 | 2006-09-05 17:34:52 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import sys |
| 4 | sys.path.append('./gen-py') |
| 5 | |
| 6 | import ThriftTest |
| 7 | from ThriftTest_types import * |
| 8 | from thrift.transport import TSocket |
| 9 | from thrift.protocol import TBinaryProtocol |
| 10 | from thrift.server import TServer |
| 11 | |
| 12 | class TestHandler: |
| 13 | |
| 14 | def testVoid(self): |
| 15 | print 'testVoid()' |
| 16 | |
| 17 | def testString(self, str): |
| 18 | print 'testString(%s)' % str |
| 19 | return str |
| 20 | |
| 21 | def testByte(self, byte): |
| 22 | print 'testByte(%d)' % byte |
| 23 | return byte |
| 24 | |
| 25 | def testException(self, str): |
| 26 | print 'testException(%s)' % str |
| 27 | x = Xception() |
| 28 | x.errorCode = 1001 |
| 29 | x.message = str |
| 30 | raise x |
| 31 | |
| 32 | transport = TSocket.TServerSocket(9090) |
| 33 | protocol = TBinaryProtocol.TBinaryProtocol() |
| 34 | handler = TestHandler() |
| 35 | iface = ThriftTest.Server(handler, protocol) |
| 36 | server = TServer.TSimpleServer(iface, transport) |
| 37 | server.run() |