Commit 2d35ac93 authored by Vincent Pelletier's avatar Vincent Pelletier

Stop using assertions for actual runtime checks.

parent c93a786f
...@@ -78,8 +78,8 @@ class NeoCTL(object): ...@@ -78,8 +78,8 @@ class NeoCTL(object):
""" """
packet = Packets.AddPendingNodes(uuid_list) packet = Packets.AddPendingNodes(uuid_list)
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.Error if response[0] != Packets.Error or response[1] != ErrorCodes.ACK:
assert response[1] == ErrorCodes.ACK raise RuntimeError(response)
return response[2] return response[2]
def setClusterState(self, state): def setClusterState(self, state):
...@@ -88,8 +88,8 @@ class NeoCTL(object): ...@@ -88,8 +88,8 @@ class NeoCTL(object):
""" """
packet = Packets.SetClusterState(state) packet = Packets.SetClusterState(state)
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.Error if response[0] != Packets.Error or response[1] != ErrorCodes.ACK:
assert response[1] == ErrorCodes.ACK raise RuntimeError(response)
return response[2] return response[2]
def setNodeState(self, node, state, update_partition_table=False): def setNodeState(self, node, state, update_partition_table=False):
...@@ -102,8 +102,8 @@ class NeoCTL(object): ...@@ -102,8 +102,8 @@ class NeoCTL(object):
update_partition_table = 0 update_partition_table = 0
packet = Packets.SetNodeState(node, state, update_partition_table) packet = Packets.SetNodeState(node, state, update_partition_table)
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.Error if response[0] != Packets.Error or response[1] != ErrorCodes.ACK:
assert response[1] == ErrorCodes.ACK raise RuntimeError(response)
return response[2] return response[2]
def getClusterState(self): def getClusterState(self):
...@@ -112,7 +112,8 @@ class NeoCTL(object): ...@@ -112,7 +112,8 @@ class NeoCTL(object):
""" """
packet = Packets.AskClusterState() packet = Packets.AskClusterState()
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.AnswerClusterState if response[0] != Packets.AnswerClusterState:
raise RuntimeError(response)
return response[1] return response[1]
def getNodeList(self, node_type=None): def getNodeList(self, node_type=None):
...@@ -121,7 +122,8 @@ class NeoCTL(object): ...@@ -121,7 +122,8 @@ class NeoCTL(object):
""" """
packet = Packets.AskNodeList(node_type) packet = Packets.AskNodeList(node_type)
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.AnswerNodeList if response[0] != Packets.AnswerNodeList:
raise RuntimeError(response)
return response[1] # node_list return response[1] # node_list
def getPartitionRowList(self, min_offset=0, max_offset=0, node=None): def getPartitionRowList(self, min_offset=0, max_offset=0, node=None):
...@@ -131,7 +133,8 @@ class NeoCTL(object): ...@@ -131,7 +133,8 @@ class NeoCTL(object):
""" """
packet = Packets.AskPartitionList(min_offset, max_offset, node) packet = Packets.AskPartitionList(min_offset, max_offset, node)
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.AnswerPartitionList if response[0] != Packets.AnswerPartitionList:
raise RuntimeError(response)
return response[1:3] # ptid, row_list return response[1:3] # ptid, row_list
def startCluster(self): def startCluster(self):
...@@ -153,6 +156,7 @@ class NeoCTL(object): ...@@ -153,6 +156,7 @@ class NeoCTL(object):
""" """
packet = Packets.AskPrimary() packet = Packets.AskPrimary()
response = self.__ask(packet) response = self.__ask(packet)
assert response[0] == Packets.AnswerPrimary if response[0] != Packets.AnswerPrimary:
raise RuntimeError(response)
return response[1] return response[1]
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