Commit 11522cd5 authored by Aurel's avatar Aurel

fix many typo and wrong method definition


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@59 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 424ddc48
...@@ -16,7 +16,7 @@ from protocol import ERROR, REQUEST_NODE_IDENTIFICATION, ACCEPT_NODE_IDENTIFICAT ...@@ -16,7 +16,7 @@ from protocol import ERROR, REQUEST_NODE_IDENTIFICATION, ACCEPT_NODE_IDENTIFICAT
ASK_NEW_OIDS, ANSWER_NEW_OIDS, ASK_STORE_OBJECT, ANSWER_STORE_OBJECT, \ ASK_NEW_OIDS, ANSWER_NEW_OIDS, ASK_STORE_OBJECT, ANSWER_STORE_OBJECT, \
ABORT_TRANSACTION, ASK_STORE_TRANSACTION, ANSWER_STORE_TRANSACTION, \ ABORT_TRANSACTION, ASK_STORE_TRANSACTION, ANSWER_STORE_TRANSACTION, \
ASK_OBJECT_BY_OID, ANSWER_OBJECT_BY_OID, ASK_TIDS, ANSWER_TIDS, ASK_TRANSACTION_INFORMATION, \ ASK_OBJECT_BY_OID, ANSWER_OBJECT_BY_OID, ASK_TIDS, ANSWER_TIDS, ASK_TRANSACTION_INFORMATION, \
ANSWER_TRANSACTION_INFORMATION, ASK_OBJETC_HISTORY, ANSWER_OBJETC_HISTORY, \ ANSWER_TRANSACTION_INFORMATION, ASK_OBJECT_HISTORY, ANSWER_OBJECT_HISTORY, \
NOT_READY_CODE, OID_NOT_FOUND_CODE, SERIAL_NOT_FOUND_CODE, TID_NOT_FOUND_CODE, \ NOT_READY_CODE, OID_NOT_FOUND_CODE, SERIAL_NOT_FOUND_CODE, TID_NOT_FOUND_CODE, \
PROTOCOL_ERROR_CODE, TIMEOUT_ERROR_CODE, BROKEN_NODE_DISALLOWED_CODE, \ PROTOCOL_ERROR_CODE, TIMEOUT_ERROR_CODE, BROKEN_NODE_DISALLOWED_CODE, \
INTERNAL_ERROR_CODE INTERNAL_ERROR_CODE
...@@ -62,7 +62,7 @@ class EventHandler(object): ...@@ -62,7 +62,7 @@ class EventHandler(object):
def packetMalformed(self, conn, packet, error_message): def packetMalformed(self, conn, packet, error_message):
"""Called when a packet is malformed.""" """Called when a packet is malformed."""
logging.info('malformed packet from %s:%d: %s', logging.info('malformed packet from %s:%d: %s',
conn.getAddress()[0], conn.getAddress()[1], error_message) conn.getAddress()[0], conn.getAddress()[1], error_message)
conn.addPacket(Packet().protocolError(packet.getId(), error_message)) conn.addPacket(Packet().protocolError(packet.getId(), error_message))
conn.abort() conn.abort()
...@@ -232,24 +232,24 @@ class EventHandler(object): ...@@ -232,24 +232,24 @@ class EventHandler(object):
serial_end, compression, checksum, data): serial_end, compression, checksum, data):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAskTIDs(self, first, last, spec): def handleAskTIDs(self, conn, packet, first, last, spec):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAnswerTIDs(self, tid_list): def handleAnswerTIDs(self, conn, packet, tid_list):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, conn, packet, packet)
def handleAskTransactionInformation(self, tid): def handleAskTransactionInformation(self, conn, packet, tid):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAnswerTransactionInformation(self, tid, user, desc, oid_list): def handleAnswerTransactionInformation(self, conn, packet, tid, user, desc, oid_list):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAskObjectHistory(self, oid, length): def handleAskObjectHistory(self, conn, packet, oid, length):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
def handleAnswerObjectHistory(self, oid, history_list): def handleAnswerObjectHistory(self, conn, packet, oid, history_list):
self.handleUnexpectedPacket(conn, packet) self.handleUnexpectedPacket(conn, packet)
# Error packet handlers. # Error packet handlers.
handleNotReady = handleUnexpectedPacket handleNotReady = handleUnexpectedPacket
...@@ -305,11 +305,11 @@ class EventHandler(object): ...@@ -305,11 +305,11 @@ class EventHandler(object):
d[NOTIFY_INFORMATION_LOCKED] = self.handleNotifyInformationLocked d[NOTIFY_INFORMATION_LOCKED] = self.handleNotifyInformationLocked
d[INVALIDATE_OBJECTS] = self.handleInvalidateObjects d[INVALIDATE_OBJECTS] = self.handleInvalidateObjects
d[UNLOCK_INFORMATION] = self.handleUnlockInformation d[UNLOCK_INFORMATION] = self.handleUnlockInformation
d[ASK_NEW_OIDS] = self.handleAskNewOids d[ASK_NEW_OIDS] = self.handleAskNewOIDs
d[ANSWER_NEW_OIDS] = self.handleAnswerNewOids d[ANSWER_NEW_OIDS] = self.handleAnswerNewOIDs
d[ASK_STORE_OBJECT] = self.handleAskStoreObject d[ASK_STORE_OBJECT] = self.handleAskStoreObject
d[ANSWER_STORE_OBJECT] = self.handleAnswerStoreObject d[ANSWER_STORE_OBJECT] = self.handleAnswerStoreObject
d[ABORT_TRANSACTION] = self.handleAbortTransaction d[ABORT_TRANSACTION] = self.handleAbortTransaction
d[ASK_STORE_TRANSACTION] = self.handleAskStoreTransaction d[ASK_STORE_TRANSACTION] = self.handleAskStoreTransaction
d[ANSWER_STORE_TRANSACTION] = self.handleAnswerStoreTransaction d[ANSWER_STORE_TRANSACTION] = self.handleAnswerStoreTransaction
d[ASK_OBJECT_BY_OID] = self.handleAskObjectByOID d[ASK_OBJECT_BY_OID] = self.handleAskObjectByOID
...@@ -320,7 +320,7 @@ class EventHandler(object): ...@@ -320,7 +320,7 @@ class EventHandler(object):
d[ANSWER_TRANSACTION_INFORMATION] = self.handleAnswerTransactionInformation d[ANSWER_TRANSACTION_INFORMATION] = self.handleAnswerTransactionInformation
d[ASK_OBJECT_HISTORY] = self.handleAskObjectHistory d[ASK_OBJECT_HISTORY] = self.handleAskObjectHistory
d[ANSWER_OBJECT_HISTORY] = self.handleAnswerObjectHistory d[ANSWER_OBJECT_HISTORY] = self.handleAnswerObjectHistory
self.packet_dispatch_table = d self.packet_dispatch_table = d
def initErrorDispatchTable(self): def initErrorDispatchTable(self):
......
...@@ -152,7 +152,7 @@ ASK_TIDS = 0x001d ...@@ -152,7 +152,7 @@ ASK_TIDS = 0x001d
ANSWER_TIDS = 0x801d ANSWER_TIDS = 0x801d
# Ask information about a transaction. PM, C -> S. # Ask information about a transaction. PM, C -> S.
ASK_TRANSACTION_INFORMATION = 0xOO1e ASK_TRANSACTION_INFORMATION = 0x001e
# Answer information (user, description) about a transaction. S -> C, PM. # Answer information (user, description) about a transaction. S -> C, PM.
ANSWER_TRANSACTION_INFORMATION = 0x801e ANSWER_TRANSACTION_INFORMATION = 0x801e
...@@ -194,7 +194,7 @@ OUT_OF_DATE_STATE = 1 ...@@ -194,7 +194,7 @@ OUT_OF_DATE_STATE = 1
FEEDING_STATE = 2 FEEDING_STATE = 2
DISCARDED_STATE = 3 DISCARDED_STATE = 3
VALID_CELL_STATE_LIST = (UP_TO_DATE_STATE, OUT_OF_DATE_STATE, FEEDING_STATE, VALID_CELL_STATE_LIST = (UP_TO_DATE_STATE, OUT_OF_DATE_STATE, FEEDING_STATE,
DISCARDED_STATE) DISCARDED_STATE)
# Other constants. # Other constants.
...@@ -220,10 +220,10 @@ class Packet(object): ...@@ -220,10 +220,10 @@ class Packet(object):
return None return None
msg_id, msg_type, msg_len = unpack('!LHL', msg[:10]) msg_id, msg_type, msg_len = unpack('!LHL', msg[:10])
if msg_len > MAX_PACKET_SIZE: if msg_len > MAX_PACKET_SIZE:
raise ProtocolError(cls(msg_id, msg_type), raise ProtocolError(cls(msg_id, msg_type),
'message too big (%d)' % msg_len) 'message too big (%d)' % msg_len)
if msg_len < MIN_PACKET_SIZE: if msg_len < MIN_PACKET_SIZE:
raise ProtocolError(cls(msg_id, msg_type), raise ProtocolError(cls(msg_id, msg_type),
'message too small (%d)' % msg_len) 'message too small (%d)' % msg_len)
if len(msg) < msg_len: if len(msg) < msg_len:
# Not enough. # Not enough.
...@@ -269,7 +269,7 @@ class Packet(object): ...@@ -269,7 +269,7 @@ class Packet(object):
return self.error(msg_id, NOT_READY_CODE, 'not ready: ' + error_message) return self.error(msg_id, NOT_READY_CODE, 'not ready: ' + error_message)
def brokenNodeDisallowedError(self, msg_id, error_message): def brokenNodeDisallowedError(self, msg_id, error_message):
return self.error(msg_id, BROKEN_NODE_DISALLOWED_ERROR, return self.error(msg_id, BROKEN_NODE_DISALLOWED_ERROR,
'broken node disallowed error: ' + error_message) 'broken node disallowed error: ' + error_message)
def ping(self, msg_id): def ping(self, msg_id):
...@@ -295,8 +295,8 @@ class Packet(object): ...@@ -295,8 +295,8 @@ class Packet(object):
port, num_partitions, num_replicas): port, num_partitions, num_replicas):
self._id = msg_id self._id = msg_id
self._type = ACCEPT_NODE_IDENTIFICATION self._type = ACCEPT_NODE_IDENTIFICATION
self._body = pack('!H16s4sHLL', node_type, uuid, self._body = pack('!H16s4sHLL', node_type, uuid,
inet_aton(ip_address), port, inet_aton(ip_address), port,
num_partitions, num_replicas) num_partitions, num_replicas)
return self return self
...@@ -517,7 +517,7 @@ class Packet(object): ...@@ -517,7 +517,7 @@ class Packet(object):
user_len = len(user) user_len = len(user)
desc_len = len(desc) desc_len = len(desc)
ext_len = len(ext) ext_len = len(ext)
body = [pack('!8sLHHH' tid, len(oid_list), user_len, desc_len, ext_len)] body = [pack('!8sLHHH', tid, len(oid_list), user_len, desc_len, ext_len)]
body.append(user) body.append(user)
body.append(desc) body.append(desc)
body.append(ext) body.append(ext)
...@@ -534,10 +534,10 @@ class Packet(object): ...@@ -534,10 +534,10 @@ class Packet(object):
def askStoreObject(self, msg_id, oid, serial, compression, checksum, data, tid): def askStoreObject(self, msg_id, oid, serial, compression, checksum, data, tid):
self._id = msg_id self._id = msg_id
self._type = ASK_STORE_OBJECT self._type = ASK_STORE_OBJECT
self._body = pack('!8s8s8sBLL', oid, serial, tid, compression, self._body = pack('!8s8s8sBLL', oid, serial, tid, compression,
checksum, len(data)) + data checksum, len(data)) + data
return self return self
def answerStoreObject(self, msg_id, conflicting, oid, serial): def answerStoreObject(self, msg_id, conflicting, oid, serial):
self._id = msg_id self._id = msg_id
self._type = ANSWER_STORE_OBJECT self._type = ANSWER_STORE_OBJECT
...@@ -549,12 +549,12 @@ class Packet(object): ...@@ -549,12 +549,12 @@ class Packet(object):
self._type = ASK_OBJET_BY_OID self._type = ASK_OBJET_BY_OID
self._body = pack('!8s8s', oid, serial) self._body = pack('!8s8s', oid, serial)
return self return self
def answerObjectByOID(self, msg_id, oid, serial_start, serial_end, compression, def answerObjectByOID(self, msg_id, oid, serial_start, serial_end, compression,
checksum, data): checksum, data):
self._id = msg_id self._id = msg_id
self._type = ANSWER_OBJECT_BY_OID self._type = ANSWER_OBJECT_BY_OID
self._body = pack('!8s8s8sBLL', oid, serial_start, serial_end, compression, self._body = pack('!8s8s8sBLL', oid, serial_start, serial_end, compression,
checksum, len(data)) + data checksum, len(data)) + data
return self return self
...@@ -581,7 +581,7 @@ class Packet(object): ...@@ -581,7 +581,7 @@ class Packet(object):
self._type = ASK_TRANSACTION_INFORMATION self._type = ASK_TRANSACTION_INFORMATION
self._body = pack('!8s', tid) self._body = pack('!8s', tid)
return self return self
def answerTransactionInformation(self, msg_id, tid, user, desc, oid_list): def answerTransactionInformation(self, msg_id, tid, user, desc, oid_list):
self._id = msg_id self._id = msg_id
self._type = ANSWER_TRANSACTION_INFORMATION self._type = ANSWER_TRANSACTION_INFORMATION
...@@ -607,7 +607,7 @@ class Packet(object): ...@@ -607,7 +607,7 @@ class Packet(object):
body.append(pack('8sL', history_tuple[0], history_tuple[1])) body.append(pack('8sL', history_tuple[0], history_tuple[1]))
self._body = ''.join(body) self._body = ''.join(body)
return self return self
# Decoders. # Decoders.
def decode(self): def decode(self):
try: try:
...@@ -951,8 +951,8 @@ class Packet(object): ...@@ -951,8 +951,8 @@ class Packet(object):
raise ProtocolError(self, 'invalid data size') raise ProtocolError(self, 'invalid data size')
return oid, serial, tid, compression, checksum, data return oid, serial, tid, compression, checksum, data
decode_table[ASK_STORE_OBJECT] = _decodeAskStoreObject decode_table[ASK_STORE_OBJECT] = _decodeAskStoreObject
def _decodeAnswerStoreObject(self): def _decodeAnswerStoreObject(self):
try: try:
conflicting, oid, serial = unpack('!B8s8s', self._body) conflicting, oid, serial = unpack('!B8s8s', self._body)
except: except:
...@@ -975,12 +975,12 @@ class Packet(object): ...@@ -975,12 +975,12 @@ class Packet(object):
for i in xrange(oid_len): for i in xrange(oid_len):
oid = unpack('8s', self._body[offset:offset+8]) oid = unpack('8s', self._body[offset:offset+8])
offset += 8 offset += 8
oid_list.append(oid) oid_list.append(oid)
except: except:
raise ProtocolError(self, 'invalid ask store transaction') raise ProtocolError(self, 'invalid ask store transaction')
return tid, user, desc, ext, oid_list return tid, user, desc, ext, oid_list
decode_table[ASK_STORE_TRANSACTION] = _decodeAskStoreTransaction decode_table[ASK_STORE_TRANSACTION] = _decodeAskStoreTransaction
def _decodeAnswerStoreTransaction(self): def _decodeAnswerStoreTransaction(self):
try: try:
tid = unpack('8s', self._body) tid = unpack('8s', self._body)
...@@ -996,8 +996,8 @@ class Packet(object): ...@@ -996,8 +996,8 @@ class Packet(object):
raise ProtocolError(self, 'invalid ask object by oid') raise ProtocolError(self, 'invalid ask object by oid')
return oid, serial return oid, serial
decode_table[ASK_OBJECT_BY_OID] = _decodeAskObjectByOID decode_table[ASK_OBJECT_BY_OID] = _decodeAskObjectByOID
def _decodeAnswerObjectByOID(self): def _decodeAnswerObjectByOID(self):
try: try:
oid, serial_start, serial_end, compression, checksum, data_len \ oid, serial_start, serial_end, compression, checksum, data_len \
= unpack('!8s8s8sBLL', self._body[:33]) = unpack('!8s8s8sBLL', self._body[:33])
...@@ -1039,7 +1039,7 @@ class Packet(object): ...@@ -1039,7 +1039,7 @@ class Packet(object):
raise ProtocolError(self, 'invalid answer tids') raise ProtocolError(self, 'invalid answer tids')
return tid_list return tid_list
decode_table[ANSWER_TIDS] = _decodeAnswerTIDs decode_table[ANSWER_TIDS] = _decodeAnswerTIDs
def _decodeAskTransactionInformation(self): def _decodeAskTransactionInformation(self):
try: try:
tid = unpack('8s', self._body) tid = unpack('8s', self._body)
...@@ -1058,11 +1058,11 @@ class Packet(object): ...@@ -1058,11 +1058,11 @@ class Packet(object):
offset += desc_len offset += desc_len
oid_list = [] oid_list = []
for i in xrange(oid_len): for i in xrange(oid_len):
oid_list.append(unpack('8s', self._body[offset+i*8:offset+8+i*8])) oid_list.append(unpack('8s', self._body[offset+i*8:offset+8+i*8]))
except: except:
raise ProtocolError(self, 'invalid answer transaction information') raise ProtocolError(self, 'invalid answer transaction information')
return tid, user, desc return tid, user, desc
decode_table[ANSWER_TRANSACTION_INFORMATION] = _decodeAnswerTransationInformation decode_table[ANSWER_TRANSACTION_INFORMATION] = _decodeAnswerTransactionInformation
def _decodeAskObjectHistory(self): def _decodeAskObjectHistory(self):
try: try:
...@@ -1078,9 +1078,9 @@ class Packet(object): ...@@ -1078,9 +1078,9 @@ class Packet(object):
history_list = () history_list = ()
for x in xrange(length): for x in xrange(length):
serial, size = unpack('!8sL', self._body[10+i*12:22+i*12]) serial, size = unpack('!8sL', self._body[10+i*12:22+i*12])
history_list.append(tuple(serial, size)) history_list.append(tuple(serial, size))
except: except:
raise ProtocolError(self, 'invalid answer object history') raise ProtocolError(self, 'invalid answer object history')
return oid, history_list return oid, history_list
decode_table[ANSWER_OBJECT_HISTORY] = _decodeAnswerObjectHistory decode_table[ANSWER_OBJECT_HISTORY] = _decodeAnswerObjectHistory
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment