diff --git a/katran/lib/testing/fplane_testing.py b/katran/lib/testing/fplane_testing.py index 959d650cb..ed77c109d 100644 --- a/katran/lib/testing/fplane_testing.py +++ b/katran/lib/testing/fplane_testing.py @@ -13,7 +13,6 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from __future__ import absolute_import, division, print_function import argparse import time @@ -191,7 +190,7 @@ def __init__(self, args, queue): self._queue = queue def sniff_packets(self): - pcap_filter = "ether src host {}".format(self._katran_mac) + pcap_filter = f"ether src host {self._katran_mac}" sniff(filter=pcap_filter, iface=self._iface, prn=self.process_received_packet) def send_test_pckts(self): @@ -224,9 +223,9 @@ def read_queue(self): def print_test_results(self): for test in self._recved_pckts.values(): - print("test: {:70} passed".format(test)) + print(f"test: {test:70} passed") for test in self._missed_pckts.values(): - print("test: {:70} failed".format(test)) + print(f"test: {test:70} failed") def process_received_packet(self, packet): if self._verbose: diff --git a/tools/tcpdump_encap_helper/tcpdump_encap_helper.py b/tools/tcpdump_encap_helper/tcpdump_encap_helper.py index 05862b1a0..fb70728d6 100755 --- a/tools/tcpdump_encap_helper/tcpdump_encap_helper.py +++ b/tools/tcpdump_encap_helper/tcpdump_encap_helper.py @@ -42,7 +42,7 @@ def ipv4_in_hex(addr): @param string addr ipv4 address @return string hex representation of this address """ - return "0x{:08X}".format(int(ipaddress.ip_address(addr))) + return f"0x{int(ipaddress.ip_address(addr)):08X}" def ip6_exploded(addr): @@ -51,8 +51,7 @@ def ip6_exploded(addr): @return list ipv6 addresses splited into 4 groups by 32bit each """ return [ - "0x{:04X}".format(x) - for x in struct.unpack("!IIII", ipaddress.ip_address(addr).packed) + f"0x{x:04X}" for x in struct.unpack("!IIII", ipaddress.ip_address(addr).packed) ] @@ -68,9 +67,7 @@ def modify_filter(tcpdump_filters, value, offset, size, v6=False): packet_type = "ip" if v6: packet_type = "ip6" - tcpdump_filters.append( - "({}[{}:{}] == {} )".format(packet_type, offset, size, value) - ) + tcpdump_filters.append(f"({packet_type}[{offset}:{size}] == {value} )") return tcpdump_filters