Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unlimited data size transfers now work both ways.

  • Loading branch information...
commit 9b4543b8d8855e2fc5de1a066b2fb1291dd69308 1 parent 702cb7f
@HughMacdonald HughMacdonald authored
Showing with 43 additions and 17 deletions.
  1. +18 −2 nukeCommandClient.py
  2. +25 −15 nukeCommandServer.py
View
20 nukeCommandClient.py
@@ -5,6 +5,8 @@
listTypes = [list, tuple, set, frozenset]
dictTypes = [dict]
+MAX_SOCKET_BYTES = 16384
+
class NukeConnectionError(StandardError):
pass
@@ -51,8 +53,22 @@ def test_connection(self):
def get(self, item_type, item_id = -1, parameters = None):
try:
data = {'action': item_type, 'id': item_id, 'parameters': parameters}
- returnData = self.send(pickle.dumps(self.encode(data)))
- result = pickle.loads(returnData)
+ encoded = pickle.dumps(self.encode(data))
+
+ if len(encoded) > MAX_SOCKET_BYTES:
+ encodedBits = []
+ while encoded:
+ encodedBits.append(encoded[:MAX_SOCKET_BYTES])
+ encoded = encoded[MAX_SOCKET_BYTES:]
+
+ for i in range(len(encodedBits)):
+ result = pickle.loads(self.send(pickle.dumps({'type': "NukeTransferPartialObject", 'part': i, 'part_count': len(encodedBits), 'data': encodedBits[i]})))
+ if i < (len(encodedBits) - 1):
+ if not (isinstance(result, dict) and 'type' in result and result['type'] == "NukeTransferPartialObjectRequest" and 'part' in result and result['part'] == i+1):
+ raise NukeConnectionError("Unexpected response to partial object")
+ else:
+ result = pickle.loads(self.send(encoded))
+
if isinstance(result, dict) and 'type' in result and result['type'] == "NukeTransferPartialObject":
data = result['data']
nextPart = 1
View
40 nukeCommandServer.py
@@ -130,23 +130,33 @@ def receive(self, data_string):
if data['part'] in self.partialObjects:
encoded = self.partialObjects[data['part']]
del self.partialObjects[data['part']]
- else:
- result = self.get(data)
+ return encoded
+
+ if isinstance(data, dict) and 'type' in data and data['type'] == "NukeTransferPartialObject":
+ if data['part'] == 0:
+ self.partialData = ""
+ self.partialData += data['data']
+
+ if data['part'] == (data['part_count'] - 1):
+ data = pickle.loads(self.partialData)
+ else:
+ nextPart = data['part'] + 1
+ return pickle.dumps({'type': "NukeTransferPartialObjectRequest", 'part': nextPart})
+
+ encoded = self.encode(self.get(data))
+
+ if len(encoded) > MAX_SOCKET_BYTES:
+ encodedBits = []
+ while encoded:
+ encodedBits.append(encoded[:MAX_SOCKET_BYTES])
+ encoded = encoded[MAX_SOCKET_BYTES:]
- encoded = self.encode(result)
+ self.partialObjects = {}
+ for i in range(len(encodedBits)):
+ self.partialObjects[i] = pickle.dumps({'type': "NukeTransferPartialObject", 'part': i, 'part_count': len(encodedBits), 'data': encodedBits[i]})
- if len(encoded) > MAX_SOCKET_BYTES:
- encodedBits = []
- while encoded:
- encodedBits.append(encoded[:MAX_SOCKET_BYTES])
- encoded = encoded[MAX_SOCKET_BYTES:]
-
- self.partialObjects = {}
- for i in range(len(encodedBits)):
- self.partialObjects[i] = pickle.dumps({'type': "NukeTransferPartialObject", 'part': i, 'part_count': len(encodedBits), 'data': encodedBits[i]})
-
- encoded = self.partialObjects[0]
- del self.partialObjects[0]
+ encoded = self.partialObjects[0]
+ del self.partialObjects[0]
return encoded
Please sign in to comment.
Something went wrong with that request. Please try again.