Thrift and Python: Made to be together

Summary: Python client code generation for Thrift... HOTNESS!

Notes: Servers and asynchronous clients are coming soon...


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664779 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/py/Makefile b/test/py/Makefile
new file mode 100644
index 0000000..05943dd
--- /dev/null
+++ b/test/py/Makefile
@@ -0,0 +1,18 @@
+# Makefile for Thrift test project.
+# 
+# Author:
+#   Mark Slee <mcslee@facebook.com>
+
+# Default target is everything
+target: all
+
+# Tools
+THRIFT = thrift
+
+all: stubs
+
+stubs: ../ThriftTest.thrift
+	$(THRIFT) --py ../ThriftTest.thrift
+
+clean:
+	rm -fr gen-py
diff --git a/test/py/TestClient.py b/test/py/TestClient.py
new file mode 100755
index 0000000..a64b8d7
--- /dev/null
+++ b/test/py/TestClient.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import sys
+sys.path.append('./gen-py')
+
+import ThriftTest
+from ThriftTest_types import *
+from thrift.transport import TSocket
+from thrift.protocol import TBinaryProtocol
+
+transport = TSocket.TSocket('localhost', 9090)
+protocol = TBinaryProtocol.TBinaryProtocol()
+client = ThriftTest.Client(transport, protocol)
+
+transport.open()
+
+print "testVoid()"
+print client.testVoid()
+
+print "testString('PythonTest')"
+print client.testString('PythonTest')
+
+print "testByte(63)"
+print client.testByte(63)
+
+print "testException('Safe')"
+print client.testException('Safe')
+
+print "textException('Xception')"
+try:
+  print client.testException('Xception')
+except Xception, x:
+  print 'Xception (%d, %s)' % (x.errorCode, x.message)
+
+transport.close()