bug-fix: 'bytes' type in python3 cause command fail

'str' type in python2 is 'bytes' type in python3,
when use python3, we will get a prefix 'b':

sudo ip netns exec b'qrouter-39cc2b45-a27c-49c5-94a6-26443a49ac63' ip
neigh
--------------------------------------------------------------------------
*** Failed to run 'sudo ip netns exec
b'qrouter-39cc2b45-a27c-49c5-94a6-26443a49ac63' ip neigh': Command 'sudo
ip netns exec b'qrouter-39cc2b45-a27c-49c5-94a6-26443a49ac63' ip neigh'
returned non-zero exit status 1.

The message above is raised by running tools/worlddump.py with python3.

Change-Id: Ic254af86fa27729839f00c0ad4a5bbbc9e545a09
This commit is contained in:
LuyaoZhong 2020-02-19 08:16:03 +00:00
parent 60a2a89232
commit 8d4ae4ffc4
1 changed files with 2 additions and 2 deletions

4
tools/worlddump.py Normal file → Executable file
View File

@ -174,7 +174,7 @@ def network_dump():
_dump_cmd("ip %s" % cmd)
for netns_ in _netns_list():
for cmd in ip_cmds:
args = {'netns': netns_, 'cmd': cmd}
args = {'netns': bytes.decode(netns_), 'cmd': cmd}
_dump_cmd('sudo ip netns exec %(netns)s ip %(cmd)s' % args)
@ -195,7 +195,7 @@ def ovs_dump():
_dump_cmd("sudo ovs-vsctl show")
for ofctl_cmd in ofctl_cmds:
for bridge in bridges:
args = {'vers': vers, 'cmd': ofctl_cmd, 'bridge': bridge}
args = {'vers': vers, 'cmd': ofctl_cmd, 'bridge': bytes.decode(bridge)}
_dump_cmd("sudo ovs-ofctl --protocols=%(vers)s %(cmd)s %(bridge)s" % args)