Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ More information about Black, you find at

The following software is required to run PTF:

* Python 2.7 or 3.x
* Python 3.x
* six 1.16.0
* Scapy 2.4.5 (unless you provide another packet manipulation module)
* pypcap (optional - VLAN tests will fail without this)
Expand Down
5 changes: 1 addition & 4 deletions ptf_nn/ptf_nn_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,7 @@ def forward(self, p, port):
msg = struct.pack("<iii{}s".format(len(p)), self.MSG_TYPE_PACKET_OUT,
port, len(p), p)
# because nnpy expects unicode when using str
if sys.version_info[0] == 2:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice job finding this one :P

msg = list(bytes(msg))
else:
msg = bytearray(msg)
msg = bytearray(msg)

self.socket.send(msg)

Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
six==1.16.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package_dir=
packages = find:
scripts = ptf, ptf_nn/ptf_nn_agent.py
platforms = any
python_requires = >=2.7, >=3
python_requires = >=3
setup_requires =
setuptools_scm
install_requires = file: requirements.txt
Expand Down
7 changes: 2 additions & 5 deletions src/ptf/dataplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from . import mask
from . import packet
from .pcap_writer import PcapWriter
from six import StringIO
from io import StringIO

try:
import nnpy
Expand Down Expand Up @@ -321,10 +321,7 @@ def send(self, port_number, packet):
packet,
)
# because nnpy expects unicode when using str
if sys.version_info[0] == 2:
msg = list(msg)
else:
msg = bytearray(msg)
msg = bytearray(msg)
self.socket.send(msg)
# nnpy does not return the number of bytes sent
return len(packet)
Expand Down
2 changes: 1 addition & 1 deletion src/ptf/mask.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import print_function
import warnings

from six import StringIO
from io import StringIO
import sys
from . import packet

Expand Down
4 changes: 2 additions & 2 deletions src/ptf/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import ptf.parse
import ptf.ptfutils
import codecs
from six import StringIO
from io import StringIO

global skipped_test_count
skipped_test_count = 0
Expand Down Expand Up @@ -3179,7 +3179,7 @@ def ptf_ports(num=None):


def port_to_tuple(port):
if type(port) is int or (sys.version_info[0] == 2 and type(port) is int):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one must have been generated by some 2-to-3 tool...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the git commit history on this one, since it looked so strange. At one point it was less weird looking, I think something like is long in the last part instead of is int.

if type(port) is int:
return 0, port
if type(port) is tuple:
return port
Expand Down