Commit 7d6b9c87 authored by Julien Muchembled's avatar Julien Muchembled

neoctl: fix 'print node' command to get list of all nodes

Protocol is extended to allow passing None in an Enum field.
parent 759491bd
......@@ -61,9 +61,12 @@ class AdminEventHandler(EventHandler):
def askNodeList(self, conn, node_type):"ask node list for %s" %(node_type))
def node_filter(n):
return n.getType() is node_type
if node_type is None:
node_type = 'all'
node_filter = None
node_filter = lambda n: n.getType() is node_type"ask list of %s nodes", node_type)
node_list =
node_information_list = [node.asTuple() for node in node_list ]
p = Packets.AnswerNodeList(node_information_list)
......@@ -281,7 +281,7 @@ class PItem(object):
def decode(self, reader):
return self._trace(self._decode, reader)
def _encode(self, writer):
def _encode(self, writer, items):
raise NotImplementedError, self.__class__.__name__
def _decode(self, reader):
......@@ -372,15 +372,20 @@ class PEnum(PStructItem):
Encapsulate an enumeration value
def __init__(self, name, enum):
PStructItem.__init__(self, name, '!L')
PStructItem.__init__(self, name, '!l')
self._enum = enum
def _encode(self, writer, item):
assert isinstance(item, int), item
if item is None:
item = -1
assert isinstance(item, int), item
def _decode(self, reader):
code = self.unpack(reader(self.size))[0]
if code == -1:
return None
return self._enum[code]
except KeyError:
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