Mark Slee | fc89d39 | 2006-09-04 00:04:39 +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 | |
| 11 | transport = TSocket.TSocket('localhost', 9090) |
| 12 | protocol = TBinaryProtocol.TBinaryProtocol() |
| 13 | client = ThriftTest.Client(transport, protocol) |
| 14 | |
| 15 | transport.open() |
| 16 | |
| 17 | print "testVoid()" |
| 18 | print client.testVoid() |
| 19 | |
| 20 | print "testString('PythonTest')" |
| 21 | print client.testString('PythonTest') |
| 22 | |
| 23 | print "testByte(63)" |
| 24 | print client.testByte(63) |
| 25 | |
| 26 | print "testException('Safe')" |
| 27 | print client.testException('Safe') |
| 28 | |
| 29 | print "textException('Xception')" |
| 30 | try: |
| 31 | print client.testException('Xception') |
| 32 | except Xception, x: |
| 33 | print 'Xception (%d, %s)' % (x.errorCode, x.message) |
| 34 | |
| 35 | transport.close() |