summaryrefslogtreecommitdiffstats
path: root/pyload/remote/thriftbackend/Protocol.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 21:59:10 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 21:59:10 +0100
commit8e7d14bae4d3c836f029a1235eb227380acc3f75 (patch)
treeebd0679642cccb994e70a89a106b394189cb28bc /pyload/remote/thriftbackend/Protocol.py
parentMerge branch 'stable' into 0.4.10 (diff)
downloadpyload-8e7d14bae4d3c836f029a1235eb227380acc3f75.tar.xz
Fix plugins to work on 0.4.10
Diffstat (limited to 'pyload/remote/thriftbackend/Protocol.py')
-rw-r--r--pyload/remote/thriftbackend/Protocol.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/pyload/remote/thriftbackend/Protocol.py b/pyload/remote/thriftbackend/Protocol.py
new file mode 100644
index 000000000..417b45834
--- /dev/null
+++ b/pyload/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 Exception:
+ pass
+
+ return str
+
+
+class ProtocolFactory(TBinaryProtocol.TBinaryProtocolFactory):
+
+ def getProtocol(self, trans):
+ prot = Protocol(trans, self.strictRead, self.strictWrite)
+ return prot