updated protobuf to use string instead of bytes for 2/3 compatibility for now, updated default service in grpc tests, fixed byte string issues for python3 in coreapi

This commit is contained in:
Blake Harnden 2019-06-03 13:34:54 -07:00
parent 7efec88e79
commit 69b1297002
5 changed files with 23 additions and 23 deletions

View file

@ -757,7 +757,7 @@ class CoreGrpcClient(object):
"""
request = core_pb2.SaveXmlRequest(session_id=session_id)
response = self.stub.SaveXml(request)
with open(file_path, "wb") as xml_file:
with open(file_path, "w") as xml_file:
xml_file.write(response.data)
def open_xml(self, file_path):
@ -768,7 +768,7 @@ class CoreGrpcClient(object):
:return: response with opened session id
:rtype: core_pb2.OpenXmlResponse
"""
with open(file_path, "rb") as xml_file:
with open(file_path, "r") as xml_file:
data = xml_file.read()
request = core_pb2.OpenXmlRequest(data=data)
return self.stub.OpenXml(request)

View file

@ -438,14 +438,14 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
if last_check is not None:
interval = now - last_check
throughputs_event = core_pb2.ThroughputsEvent()
for key, current_rxtx in stats.iteritems():
for key in stats:
current_rxtx = stats[key]
previous_rxtx = last_stats.get(key)
if not previous_rxtx:
continue
rx_kbps = (current_rxtx["rx"] - previous_rxtx["rx"]) * 8.0 / interval
tx_kbps = (current_rxtx["tx"] - previous_rxtx["tx"]) * 8.0 / interval
throughput = rx_kbps + tx_kbps
print "%s - %s" % (key, throughput)
if key.startswith("veth"):
key = key.split(".")
node_id = int(_INTERFACE_REGEX.search(key[0]).group())
@ -922,7 +922,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
_, temp_path = tempfile.mkstemp()
session.save_xml(temp_path)
with open(temp_path, "rb") as xml_file:
with open(temp_path, "r") as xml_file:
data = xml_file.read()
return core_pb2.SaveXmlResponse(data=data)
@ -933,7 +933,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session.set_state(EventTypes.CONFIGURATION_STATE)
_, temp_path = tempfile.mkstemp()
with open(temp_path, "wb") as xml_file:
with open(temp_path, "w") as xml_file:
xml_file.write(request.data)
try:

View file

@ -219,12 +219,12 @@ class CoreTlvDataUint16List(CoreTlvData):
if not isinstance(values, tuple):
raise ValueError("value not a tuple: %s" % values)
data = ""
data = b""
for value in values:
data += struct.pack(cls.data_format, value)
pad_len = -(CoreTlv.header_len + len(data)) % 4
return len(data), data + "\0" * pad_len
return len(data), data + b"\0" * pad_len
@classmethod
def unpack(cls, data):