From 582eac5c30e78f65ba0127aed2cb7442f4122fd2 Mon Sep 17 00:00:00 2001 From: Paul Vinciguerra Date: Fri, 3 Apr 2020 12:18:40 -0400 Subject: misc: fix python sonarcloud BLOCKER level issues Fix of the top 11 python issues flagged as BLOCKER. Ticket: VPP-1856 Type: fix Change-Id: Icf4691e62f4a69d6ee196b6d6e2ab52d961b5c76 Signed-off-by: Paul Vinciguerra --- src/plugins/srv6-mobile/extra/runner.py | 2 ++ src/plugins/vrrp/test/test_vrrp.py | 9 +++++---- src/tools/vppapigen/vppapigen.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/srv6-mobile/extra/runner.py b/src/plugins/srv6-mobile/extra/runner.py index c438fb161b7..b18fdc32766 100755 --- a/src/plugins/srv6-mobile/extra/runner.py +++ b/src/plugins/srv6-mobile/extra/runner.py @@ -248,6 +248,7 @@ class Containers(object): def build(self, path, vpp_path): env = Environment(loader=FileSystemLoader(path), + autoescape=True, trim_blocks=True) self.tmp_render(join(vpp_path, "Dockerfile"), @@ -264,6 +265,7 @@ class Containers(object): def release(self, path, vpp_path): env = Environment(loader=FileSystemLoader(path), + autoescape=True, trim_blocks=True) self.tmp_render(join(vpp_path, "Dockerfile"), diff --git a/src/plugins/vrrp/test/test_vrrp.py b/src/plugins/vrrp/test/test_vrrp.py index cd2aeb10ec3..3a85d2e6b66 100644 --- a/src/plugins/vrrp/test/test_vrrp.py +++ b/src/plugins/vrrp/test/test_vrrp.py @@ -8,12 +8,13 @@ import unittest import time -from socket import inet_pton, inet_ntop, AF_INET6 +import socket +from socket import inet_pton, inet_ntop from vpp_object import VppObject from vpp_papi import VppEnum -from scapy.packet import Raw +from scapy.packet import raw from scapy.layers.l2 import Ether, ARP from scapy.layers.inet import IP, ICMP, icmptypes from scapy.layers.inet6 import IPv6, ipv6nh, IPv6ExtHdrHopByHop, \ @@ -833,8 +834,8 @@ class TestVRRP6(VppTestCase): self.assertEqual(pkt[IPv6].dst, "ff02::1") # convert addrs to packed format since string versions could differ - src_addr = inet_pton(AF_INET6, pkt[IPv6].src) - vr_ll_addr = inet_pton(AF_INET6, vr.interface().local_ip6_ll) + src_addr = inet_pton(socket.AF_INET6, pkt[IPv6].src) + vr_ll_addr = inet_pton(socket.AF_INET6, vr.interface().local_ip6_ll) self.assertEqual(src_addr, vr_ll_addr) self.assertTrue(pkt[ICMPv6ND_NA].tgt in vr.virtual_ips()) diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py index f3013aa6021..b17ad6d15c9 100755 --- a/src/tools/vppapigen/vppapigen.py +++ b/src/tools/vppapigen/vppapigen.py @@ -648,7 +648,7 @@ class VPPAPIParser(object): elif len(p) == 4: p[0] = Field(p[1], p[2]) else: - self._parse_error('ERROR') + self._parse_error('ERROR', self._token_coord(p, 1)) self.fields.append(p[2]) def p_declaration_array_vla(self, p): -- cgit 1.2.3-korg