summaryrefslogtreecommitdiffstats
path: root/module/remote/thriftbackend/Protocol.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-10 23:43:10 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-10 23:43:10 +0100
commit2b353fa266c13b77b2c77af797dc28c8380b9443 (patch)
treedb1e1b9f67cf87ffb711f91c643d665bae1bee8a /module/remote/thriftbackend/Protocol.py
parentthrift + setup fixes (diff)
downloadpyload-2b353fa266c13b77b2c77af797dc28c8380b9443.tar.xz
more fixes
Diffstat (limited to 'module/remote/thriftbackend/Protocol.py')
-rw-r--r--module/remote/thriftbackend/Protocol.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/module/remote/thriftbackend/Protocol.py b/module/remote/thriftbackend/Protocol.py
new file mode 100644
index 000000000..c42d01459
--- /dev/null
+++ b/module/remote/thriftbackend/Protocol.py
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+
+from thrift.protocol import TBinaryProtocol
+
+class Protocol(TBinaryProtocol.TBinaryProtocol):
+ def writeString(self, str):
+ try:
+ str = str.encode("utf8", "ignore")
+ except Exception, e:
+ pass
+
+ self.writeI32(len(str))
+ self.trans.write(str)
+
+ def readString(self):
+ len = self.readI32()
+ str = self.trans.readAll(len)
+ try:
+ str = str.decode("utf8", "ignore")
+ except:
+ pass
+
+ return str
+
+
+class ProtocolFactory(TBinaryProtocol.TBinaryProtocolFactory):
+
+ def getProtocol(self, trans):
+ prot = Protocol(trans, self.strictRead, self.strictWrite)
+ return prot \ No newline at end of file