Commit 8fce97a2 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Define __str__ method on Packet to help debugging, previous implementation

returned a binary string of packet content.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@885 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent a29f63a8
......@@ -423,6 +423,9 @@ class Packet(object):
def getType(self):
return self._type
def __str__(self):
return 'Packet <%s>' % self._type
def __len__(self):
try:
return PACKET_HEADER_SIZE + len(self._body)
......@@ -434,9 +437,7 @@ class Packet(object):
if len(msg) > MAX_PACKET_SIZE:
raise PacketMalformedError('message too big (%d)' % len(msg))
return msg
__str__ = encode
# Decoders.
def decode(self):
try:
method = decode_table[self._type]
......@@ -447,6 +448,7 @@ class Packet(object):
def isResponse(self):
return self._type & 0x8000 == 0x8000
# packet parser
def parse(msg):
if len(msg) < MIN_PACKET_SIZE:
......
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