1From 06050e79655f0fa7d9daeda1fbd3a9a2c7736841 Mon Sep 17 00:00:00 2001 2From: Mingli Yu <mingli.yu@windriver.com> 3Date: Thu, 2 Dec 2021 15:08:25 +0800 4Subject: [PATCH] team_basic_test.py: switch to python3 5 6Switch the script team_basic_test.py to python3 7 8Upstream-Status: Submitted [https://github.com/jpirko/libteam/pull/63] 9 10Signed-off-by: Mingli Yu <mingli.yu@windriver.com> 11--- 12 scripts/team_basic_test.py | 28 ++++++++++++++-------------- 13 1 file changed, 14 insertions(+), 14 deletions(-) 14 15diff --git a/scripts/team_basic_test.py b/scripts/team_basic_test.py 16index faabd18..0b64af2 100755 17--- a/scripts/team_basic_test.py 18+++ b/scripts/team_basic_test.py 19@@ -1,4 +1,4 @@ 20-#! /usr/bin/env python 21+#! /usr/bin/env python3 22 """ 23 Basic test. 24 25@@ -32,11 +32,11 @@ def usage(): 26 """ 27 Print usage of this app 28 """ 29- print "Usage: team_basic_test.py [OPTION...]" 30- print "" 31- print " -h, --help print this message" 32- print " -c, --loop-count=NUMBER number of loops (default 1)" 33- print " -p, --port=NETDEV port device (can be defined multiple times)" 34+ print("Usage: team_basic_test.py [OPTION...]") 35+ print("") 36+ print(" -h, --help print this message") 37+ print(" -c, --loop-count=NUMBER number of loops (default 1)") 38+ print(" -p, --port=NETDEV port device (can be defined multiple times)") 39 sys.exit() 40 41 class CmdExecFailedException(Exception): 42@@ -55,15 +55,15 @@ class CmdExecUnexpectedOutputException(Exception): 43 return "Command execution output unexpected: \"%s\" != \"%s\"" % (self.__output, self.__expected_output) 44 45 def print_output(out_type, string): 46- print("%s:\n" 47+ print(("%s:\n" 48 "----------------------------\n" 49 "%s" 50- "----------------------------" % (out_type, string)) 51+ "----------------------------" % (out_type, string))) 52 53 def cmd_exec(cmd, expected_output=None, cleaner=False): 54 cmd = cmd.rstrip(" ") 55 if not cleaner: 56- print("# \"%s\"" % cmd) 57+ print(("# \"%s\"" % cmd)) 58 subp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, 59 stderr=subprocess.PIPE) 60 (data_stdout, data_stderr) = subp.communicate() 61@@ -74,7 +74,7 @@ def cmd_exec(cmd, expected_output=None, cleaner=False): 62 if data_stderr: 63 print_output("Stderr", data_stderr) 64 raise CmdExecFailedException(subp.returncode) 65- output = data_stdout.rstrip() 66+ output = (data_stdout.rstrip()).decode() 67 if expected_output: 68 if output != expected_output: 69 raise CmdExecUnexpectedOutputException(output, expected_output) 70@@ -166,7 +166,7 @@ TEAM_PORT_CONFIG='{"prio": 10}' 71 os.removedirs("/tmp/team_test/") 72 73 def _run_one_loop(self, run_nr): 74- print "RUN #%d" % (run_nr) 75+ print("RUN #%d" % (run_nr)) 76 self._created_teams = [] 77 try: 78 for mode_name in self._team_modes: 79@@ -176,7 +176,7 @@ TEAM_PORT_CONFIG='{"prio": 10}' 80 cmd_exec("modprobe -r team_mode_loadbalance team_mode_roundrobin team_mode_activebackup team_mode_broadcast team"); 81 82 def run(self): 83- for i in xrange(self._loop_count): 84+ for i in range(self._loop_count): 85 self._run_one_loop(i + 1) 86 87 def main(): 88@@ -186,8 +186,8 @@ def main(): 89 "hc:p:", 90 ["help", "loop-count=", "port="] 91 ) 92- except getopt.GetoptError, err: 93- print str(err) 94+ except getopt.GetoptError as err: 95+ print(str(err)) 96 usage() 97 98 btest = TeamBasicTest() 99-- 1002.17.1 101 102