Skip to content

Commit

Permalink
Remove several mentions of Python 2 (#190)
Browse files Browse the repository at this point in the history
* Remove several mentions of Python 2
Not all of them are removed with these changes, because I am not sure
how best to remove some of them, e.g. in the file debian/control

* Remove uses of six package
  • Loading branch information
jafingerhut authored Jun 16, 2023
1 parent 9c1787d commit 6e1a7c5
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 15 deletions.
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:
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):
if type(port) is int:
return 0, port
if type(port) is tuple:
return port
Expand Down

0 comments on commit 6e1a7c5

Please sign in to comment.