blob: 525ffee38fdea4ba71e2d5fbf246893ac8aa6754 [file] [log] [blame]
Mark Sleec9676562006-09-05 17:34:52 +00001#!/usr/bin/python
2
3import sys
4sys.path.append('./gen-py')
5
6import ThriftTest
7from ThriftTest_types import *
8from thrift.transport import TSocket
9from thrift.protocol import TBinaryProtocol
10from thrift.server import TServer
11
12class 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
Mark Sleec98d0502006-09-06 02:42:25 +000025 def testI16(self, i16):
26 print 'testI16(%d)' % i16
27 return i16
28
29 def testI32(self, i32):
30 print 'testI32(%d)' % i32
31 return i32
32
33 def testI64(self, i64):
34 print 'testI64(%d)' % i64
35 return i64
36
37 def testDouble(self, dub):
38 print 'testDouble(%f)' % dub
39 return dub
40
41 def testStruct(self, thing):
42 print 'testStruct({%s, %d, %d, %d})' % (thing.string_thing, thing.byte_thing, thing.i32_thing, thing.i64_thing)
43 return thing
44
Mark Sleec9676562006-09-05 17:34:52 +000045 def testException(self, str):
46 print 'testException(%s)' % str
Mark Sleec98d0502006-09-06 02:42:25 +000047 if str == 'Xception':
48 x = Xception()
49 x.errorCode = 1001
50 x.message = str
51 raise x
Mark Sleec9676562006-09-05 17:34:52 +000052
53transport = TSocket.TServerSocket(9090)
54protocol = TBinaryProtocol.TBinaryProtocol()
55handler = TestHandler()
56iface = ThriftTest.Server(handler, protocol)
57server = TServer.TSimpleServer(iface, transport)
58server.run()