From 31555a3475a37195938378217a635b3451e449de Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Mon, 22 Oct 2018 09:30:26 +0200 Subject: PAPI: Add support for format/unformat functions. With the introduction of new types, like vl_api_address_t it is now possible to call a message using one of those functions with a string representation. E.g. for an IP address ip_add_address(address="1.1.1.1/24") The language wrapper will automatically convert the string into the vl_api_address_t representation. Currently the caller must do the reverse conversion from the returned named tuple with the unformat function. rv = get_address_on_interface(sw_if_index=1) print(VPPFormat.unformat(rv.address)) Change-Id: Ic872b4560b2f4836255bd5260289bfa38c75bc5d Signed-off-by: Ole Troan --- src/vpp-api/python/vpp_papi/vpp_stats.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/vpp-api/python/vpp_papi/vpp_stats.py') diff --git a/src/vpp-api/python/vpp_papi/vpp_stats.py b/src/vpp-api/python/vpp_papi/vpp_stats.py index 8c1aaf2b87a..76e1e5435f0 100644 --- a/src/vpp-api/python/vpp_papi/vpp_stats.py +++ b/src/vpp-api/python/vpp_papi/vpp_stats.py @@ -62,7 +62,8 @@ def make_string_vector(api, strings): if type(strings) is not list: strings = [strings] for s in strings: - vec = api.stat_segment_string_vector(vec, ffi.new("char []", s.encode())) + vec = api.stat_segment_string_vector(vec, ffi.new("char []", + s.encode())) return vec @@ -134,7 +135,7 @@ class VPPStats: for i in range(rv_len): n = ffi.string(rv[i].name).decode() e = stat_entry_to_python(self.api, rv[i]) - if e != None: + if e is not None: stats[n] = e return stats @@ -144,7 +145,7 @@ class VPPStats: try: dir = self.ls(name) return self.dump(dir).values()[0] - except: + except Exception as e: if retries > 10: return None retries += 1 @@ -161,7 +162,7 @@ class VPPStats: error_names = self.ls(['/err/']) error_counters = self.dump(error_names) break - except: + except Exception as e: if retries > 10: return None retries += 1 -- cgit 1.2.3-korg