summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/python/vpp_papi/vpp_papi.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/python/vpp_papi/vpp_papi.py')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_papi.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_papi.py b/src/vpp-api/python/vpp_papi/vpp_papi.py
index c37334cd4e5..32abe14da94 100644
--- a/src/vpp-api/python/vpp_papi/vpp_papi.py
+++ b/src/vpp-api/python/vpp_papi/vpp_papi.py
@@ -28,7 +28,6 @@ import weakref
import atexit
from . vpp_serializer import VPPType, VPPEnumType, VPPUnionType, BaseTypes
from . vpp_serializer import VPPMessage, vpp_get_type, VPPTypeAlias
-from . vpp_format import VPPFormat
if sys.version[0] == '2':
import Queue as queue
@@ -56,11 +55,11 @@ def vpp_atexit(vpp_weakref):
vpp_instance.logger.debug('Cleaning up VPP on exit')
vpp_instance.disconnect()
-
-def vpp_iterator(d):
- if sys.version[0] == '2':
+if sys.version[0] == '2':
+ def vpp_iterator(d):
return d.iteritems()
- else:
+else:
+ def vpp_iterator(d):
return d.items()
@@ -409,7 +408,8 @@ class VPP(object):
# Create function for client side messages.
if name in self.services:
- if 'stream' in self.services[name] and self.services[name]['stream']:
+ if 'stream' in self.services[name] and \
+ self.services[name]['stream']:
multipart = True
else:
multipart = False
@@ -493,7 +493,7 @@ class VPP(object):
else:
raise VPPIOError(2, 'RPC reply message received in event handler')
- def decode_incoming_msg(self, msg):
+ def decode_incoming_msg(self, msg, no_type_conversion=False):
if not msg:
self.logger.warning('vpp_api.read failed')
return
@@ -508,7 +508,7 @@ class VPP(object):
if not msgobj:
raise VPPIOError(2, 'Reply message undefined')
- r, size = msgobj.unpack(msg)
+ r, size = msgobj.unpack(msg, ntc=no_type_conversion)
return r
def msg_handler_async(self, msg):
@@ -535,7 +535,7 @@ class VPP(object):
d = set(kwargs.keys()) - set(msg.field_by_name.keys())
if d:
raise VPPValueError('Invalid argument {} to {}'
- .format(list(d), msg.name))
+ .format(list(d), msg.name))
def _call_vpp(self, i, msg, multipart, **kwargs):
"""Given a message, send the message and await a reply.
@@ -560,6 +560,8 @@ class VPP(object):
context = kwargs['context']
kwargs['_vl_msg_id'] = i
+ no_type_conversion = kwargs.pop('_no_type_conversion', False)
+
try:
if self.transport.socket_index:
kwargs['client_index'] = self.transport.socket_index
@@ -582,7 +584,7 @@ class VPP(object):
msg = self.transport.read()
if not msg:
raise VPPIOError(2, 'VPP API client: read failed')
- r = self.decode_incoming_msg(msg)
+ r = self.decode_incoming_msg(msg, no_type_conversion)
msgname = type(r).__name__
if context not in r or r.context == 0 or context != r.context:
# Message being queued