-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Intel Corporation
-from __future__ import print_function
import sys
import os
import argparse
print("ERROR: Test app timed out")
process.kill()
-if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
-
dpdk_path = "../.."
dpdk_target = "build"
-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
# Script that runs cmdline_test app and feeds keystrokes into it.
-from __future__ import print_function
import cmdline_test_data
import os
import pexpect
return 0
child.expect(test["Result"], 1)
-if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
-
#
# history test is a special case
#
i = 0
# fill the history with numbers
- while i < history_size / 10:
+ while i < history_size // 10:
# add 1 to prevent from parsing as octals
child.send("1" + str(i).zfill(8) + cmdline_test_data.ENTER)
# the app will simply print out the number
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
# Script that uses either test app or qemu controlled by python-pexpect
-from __future__ import print_function
import autotest_data
import autotest_runner
import sys
usage()
sys.exit(1)
-if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
-
target = sys.argv[2]
test_whitelist = None
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
# The main logic behind running autotests in parallel
-from __future__ import print_function
-import StringIO
+import io
import csv
from multiprocessing import Pool, Queue
import pexpect
map(os.path.basename, cpu_path)
)
)
- # for compatibility between python 3 and 2 we need to make interable out
- # of filter return as it returns list in python 2 and a generator in 3
- m = next(iter(cpu_name))
- return int(m.group(1))
-
+ return int(next(cpu_name).group(1))
pool_child = None # per-process child
cmdline = "%s %s" % (cmdline, prefix_cmdline)
# prepare logging of init
- startuplog = StringIO.StringIO()
+ startuplog = io.StringIO()
# run test app
try:
print("\n%s %s\n" % ("=" * 20, prefix), file=startuplog)
print("\ncmdline=%s" % cmdline, file=startuplog)
- pool_child = pexpect.spawn(cmdline, logfile=startuplog)
-
+ pool_child = pexpect.spawn(cmdline, logfile=startuplog, encoding='utf-8')
# wait for target to boot
if not wait_prompt(pool_child):
pool_child.close()
# create log buffer for each test
# in multiprocessing environment, the logging would be
# interleaved and will create a mess, hence the buffering
- logfile = StringIO.StringIO()
+ logfile = io.StringIO()
pool_child.logfile = logfile
# make a note when the test started
# parse the binary for available test commands
binary = cmdline.split()[0]
stripped = 'not stripped' not in \
- subprocess.check_output(['file', binary])
+ subprocess.check_output(['file', binary]).decode()
if not stripped:
- symbols = subprocess.check_output(['nm', binary]).decode('utf-8')
+ symbols = subprocess.check_output(['nm', binary]).decode()
self.avail_cmds = re.findall('test_register_(\w+)', symbols)
else:
self.avail_cmds = None
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2019 Intel Corporation
-from __future__ import print_function
import sys
from os.path import dirname, basename, join, exists
-#!/usr/bin/python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2017 Cavium, Inc
-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2019 Intel Corporation
from the devtools/update-abi.sh utility.
"""
-from __future__ import print_function
import argparse
import sys
import re
print("};", file=f_out)
def __main():
- if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
-
arg_parser = argparse.ArgumentParser(
description='Merge versions in linker version script.')
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2015 Intel Corporation
-from __future__ import print_function
from docutils import nodes
from distutils.version import LooseVersion
from sphinx import __version__ as sphinx_version
from os.path import dirname
from os.path import join as path_join
-try:
- # Python 2.
- import ConfigParser as configparser
-except:
- # Python 3.
- import configparser
+import configparser
try:
import sphinx_rtd_theme
Python Code
-----------
-All Python code should work with Python 2.7+ and 3.2+ and be compliant with
+All Python code should be compliant with
`PEP8 (Style Guide for Python Code) <https://www.python.org/dev/peps/pep-0008/>`_.
The ``pep8`` tool can be used for testing compliance with the guidelines.
In this case the function will return -1 unless the environment is unset first
(using ``rte_power_unset_env``). Other function usage scenarios will not change.
-* python: Since the beginning of 2020, Python 2 has officially reached
- end-of-support: https://www.python.org/doc/sunset-python-2/.
- Python 2 support will be completely removed in 20.11.
- In 20.08, explicit deprecation warnings will be displayed when running
- scripts with Python 2.
-
* dpdk-setup.sh: This old script relies on deprecated stuff, and especially
``make``. Given environments are too much variables for such a simple script,
it will be removed in DPDK 20.11.
* vhost: Dequeue zero-copy support has been removed.
+* Removed Python 2 support since it was EOL'd in January 2020.
+
API Changes
-----------
-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
# Copyright(c) 2017 Cavium, Inc. All rights reserved.
-from __future__ import print_function
-import sys
-try:
- xrange # Python 2
-except NameError:
- xrange = range # Python 3
-
-if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
-
sockets = []
cores = []
core_map = {}
fd = open("{}/kernel_max".format(base_path))
max_cpus = int(fd.read())
fd.close()
-for cpu in xrange(max_cpus + 1):
+for cpu in range(max_cpus + 1):
try:
fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu))
except IOError:
-#! /usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2010-2014 Intel Corporation
#
-from __future__ import print_function
import sys
import os
import getopt
from os.path import exists, abspath, dirname, basename
from os.path import join as path_join
-if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
-
# The PCI base class for all devices
network_class = {'Class': '02', 'Vendor': None, 'Device': None,
'SVendor': None, 'SDevice': None}
""" % locals()) # replace items from local variables
-
-# This is roughly compatible with check_output function in subprocess module
-# which is only available in python 2.7.
-def check_output(args, stderr=None):
- '''Run a command and capture its output'''
- return subprocess.Popen(args, stdout=subprocess.PIPE,
- stderr=stderr).communicate()[0]
-
# check if a specific kernel module is loaded
def module_is_loaded(module):
global loaded_modules
device = {}
if probe_lspci:
- extra_info = check_output(["lspci", "-vmmks", dev_id]).splitlines()
-
+ extra_info = subprocess.check_output(["lspci", "-vmmks", dev_id]).splitlines()
# parse lspci details
for line in extra_info:
if len(line) == 0:
# first loop through and read details for all devices
# request machine readable format, with numeric IDs and String
dev = {}
- dev_lines = check_output(["lspci", "-Dvmmnnk"]).splitlines()
+ dev_lines = subprocess.check_output(["lspci", "-Dvmmnnk"]).splitlines()
for dev_line in dev_lines:
if len(dev_line) == 0:
if device_type_match(dev, devices_type):
# check what is the interface if any for an ssh connection if
# any to this host, so we can mark it later.
ssh_if = []
- route = check_output(["ip", "-o", "route"])
+ route = subprocess.check_output(["ip", "-o", "route"])
# filter out all lines for 169.254 routes
route = "\n".join(filter(lambda ln: not ln.startswith("169.254"),
route.decode().splitlines()))
-#!/usr/bin/env python
+#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2016 Neil Horman <nhorman@tuxdriver.com>
# Utility to dump PMD_INFO_STRING support from an object file
#
# -------------------------------------------------------------------------
-from __future__ import print_function
-from __future__ import unicode_literals
import json
import io
import os
pcidb = None
# ===========================================
-if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
class Vendor:
"""
-#! /usr/bin/env python
+#! /usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Intel Corporation
-from __future__ import print_function
-from __future__ import unicode_literals
-
import socket
import os
import sys
GLOBAL_METRICS_REQ = "{\"action\":0,\"command\":\"global_stat_values\",\"data\":null}"
DEFAULT_FP = "/var/run/dpdk/default_client"
-try:
- raw_input # Python 2
-except NameError:
- raw_input = input # Python 3
-
-if sys.version_info.major < 3:
- print("WARNING: Python 2 is deprecated for use in DPDK, and will not work in future releases.", file=sys.stderr)
- print("Please use Python 3 instead", file=sys.stderr)
-
class Socket:
def __init__(self):
def repeatedlyRequestMetrics(self, sleep_time): # Recursively requests metrics for given client
print("\nPlease enter the number of times you'd like to continuously request Metrics:")
- n_requests = int(raw_input("\n:"))
+ n_requests = int(input("\n:"))
print("\033[F") #Removes the user input from screen, cleans it up
print("\033[K")
for i in range(n_requests):
print("[4] Unregister client")
try:
- self.choice = int(raw_input("\n:"))
+ self.choice = int(input("\n:"))
print("\033[F") #Removes the user input for screen, cleans it up
print("\033[K")
if self.choice == 1:
-#! /usr/bin/python3
+#! /usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2020 Intel Corporation