def _show_or_dump(self,
dump=False, # type: bool
indent=3, # type: int
lvl="", # type: str
label_lvl="", # type: str
first_call=True # type: bool
):
# type: (...) -> Optional[str]
"""
Internal method that shows or dumps a hierarchical view of a packet.
Called by show.
:param dump: determine if it prints or returns the string value
:param int indent: the size of indentation for each layer
:param str lvl: additional information about the layer lvl
:param str label_lvl: additional information about the layer fields
:param first_call: determine if the current function is the first
:return: return a hierarchical view if dump, else print it
"""
if dump:
from scapy.themes import AnsiColorTheme
ct = AnsiColorTheme() # No color for dump output
else:
ct = conf.color_theme
s = "%s%s %s %s \n" % (label_lvl,
ct.punct("###["),
ct.layer_name(self.name),
ct.punct("]###"))
for f in self.fields_desc:
if isinstance(f, ConditionalField) and not f._evalcond(self):
continue
if isinstance(f, Emph) or f in conf.emph:
ncol = ct.emph_field_name
vcol = ct.emph_field_value
else:
ncol = ct.field_name
vcol = ct.field_value
fvalue = self.getfieldval(f.name)
if isinstance(fvalue, Packet) or (f.islist and f.holds_packets and isinstance(fvalue, list)): # noqa: E501
pad = max(0, 10 - len(f.name)) * " "
s += "%s \\%s%s\\\n" % (label_lvl + lvl, ncol(f.name), pad)
fvalue_gen = SetGen(
fvalue,
_iterpacket=0
) # type: SetGen[Packet]
for fvalue in fvalue_gen:
s += fvalue._show_or_dump(dump=dump, indent=indent, label_lvl=label_lvl + lvl + " |", first_call=False) # noqa: E501
else:
pad = max(0, 10 - len(f.name)) * " "
begn = "%s %s%s%s " % (label_lvl + lvl,
ncol(f.name),
pad,
ct.punct("="),)
reprval = f.i2repr(self, fvalue)
if isinstance(reprval, str):
reprval = reprval.replace("\n", "\n" + " " * (len(label_lvl) + # noqa: E501
len(lvl) +
len(f.name) +
4))
s += "%s%s\n" % (begn, vcol(reprval))
if self.payload:
s += self.payload._show_or_dump( # type: ignore
dump=dump,
indent=indent,
lvl=lvl + (" " * indent * self.show_indent),
label_lvl=label_lvl,
first_call=False
)
if first_call and not dump:
print(s)
E TypeError: a bytes-like object is required, not 'str'
Describe the results you expected:
tests should not fail over python migration realted issue
Additional information you deem important:Output of show version:
Description
test dualtor/test_orchagent_mac_move.py is failing with python3 on error: TypeError: a bytes-like object is required, not 'str'
Steps to reproduce the issue:
Describe the results you received: def test_mac_move( announce_new_neighbor, apply_active_state_to_orchagent, conn_graph_facts, ptfadapter, ptfhost, rand_selected_dut, set_crm_polling_interval, tbinfo, tunnel_traffic_monitor, vmhost # noqa F811 ): tor = rand_selected_dut ptf_t1_intf = random.choice(get_t1_ptf_ports(tor, tbinfo)) ptf_t1_intf_index = int(ptf_t1_intf.strip("eth"))
announce_new_neighbor = <generator object announce_new_neighbor.._announce_new_neighbor_gen at 0x7fe63cec5660>
apply_active_state_to_orchagent = None
conn_graph_facts = {'device_bmc_info': {'r-tigon-20': {}}, 'device_bmc_link': {'r-tigon-20': {}}, 'device_conn': {'r-tigon-20': {'Etherne...: 'r-tigon-19', 'peerport': 'ethernet 1/28', 'speed': '100000'}, ...}}, 'device_console_info': {'r-tigon-20': {}}, ...}
ptf_t1_intf = 'eth1'
ptf_t1_intf_index = 1
ptfadapter =
ptfhost = <tests.common.devices.ptf.PTFHost object at 0x7fe641aef670>
rand_selected_dut =
set_crm_polling_interval = None
tbinfo = {'comment': 'Mellanox MTR testbed', 'conf-name': 'r-tigon-20-t0-64', 'duts': ['r-tigon-20'], 'duts_map': {'r-tigon-20': 0}, ...}
test_port = 'Ethernet44'
tor =
tunnel_traffic_monitor = <class 'tests.common.dualtor.tunnel_traffic_utils.tunnel_traffic_monitor..TunnelTrafficMonitor'>
vmhost = <tests.common.devices.vmhost.VMHost object at 0x7fe63e040760>
dualtor/test_orchagent_mac_move.py:95:
dualtor/test_orchagent_mac_move.py:52: in _announce_new_neighbor_gen NEW_NEIGHBOR_IPV4_ADDR, dut_iface, dump_scapy_packet_show_output(garp_packet) dut_iface = 'Ethernet44' dut_ifaces = ['Ethernet44', 'Ethernet36', 'Ethernet144', 'Ethernet216', 'Ethernet52', 'Ethernet208', ...] dut_to_ptf_intf_map = {'Ethernet0': 0, 'Ethernet100': 25, 'Ethernet104': 26, 'Ethernet108': 27, ...} garp_packet = <Ether dst=ff:ff:ff:ff:ff:ff src=02:AA:BB:CC:DD:EE type=ARP |<ARP op=is-at hwsrc=02:AA:BB:CC:DD:EE psrc=192.168.0.25...00:00:00 pdst=192.168.0.250 |<Raw load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>> ptf_iface = 11 ptfadapter =
update_iface_func = None
common/utilities.py:507: in dump_scapy_packet_show_output
packet.show()
_stdout = <_io.TextIOWrapper name="<_io.FileIO name=10 mode='rb+' closefd=True>" mode='r+' encoding='utf-8'>
packet = <Ether dst=ff:ff:ff:ff:ff:ff src=02:AA:BB:CC:DD:EE type=ARP |<ARP op=is-at hwsrc=02:AA:BB:CC:DD:EE psrc=192.168.0.25...00:00:00 pdst=192.168.0.250 |<Raw load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>>
/var/AzDevOps/env-python3/lib/python3.8/site-packages/scapy/packet.py:1464: in show
return self._show_or_dump(dump, indent, lvl, label_lvl)
dump = False
indent = 3
label_lvl = ''
lvl = ''
self = <Ether dst=ff:ff:ff:ff:ff:ff src=02:AA:BB:CC:DD:EE type=ARP |<ARP op=is-at hwsrc=02:AA:BB:CC:DD:EE psrc=192.168.0.25...00:00:00 pdst=192.168.0.250 |<Raw load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>>
self = <Ether dst=ff:ff:ff:ff:ff:ff src=02:AA:BB:CC:DD:EE type=ARP |<ARP op=is-at hwsrc=02:AA:BB:CC:DD:EE psrc=192.168.0.25...00:00:00 pdst=192.168.0.250 |<Raw load='\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' |>>> dump = False, indent = 3, lvl = '', label_lvl = '', first_call = True
Describe the results you expected: tests should not fail over python migration realted issue
Additional information you deem important: Output of
show version
: