Always pass str to shlex.split for py26 compat
On python 2.6 shlex.split cannot handle unicode, which can lead to TypeError exception. Details can be seen in http://bugs.python.org/issue6988 and http://bugs.python.org/issue1548891 As best solution it seems to decode *cmd* to utf-8 str before passing to shlex.split(). Change-Id: If56a6f16ab712691b26035d0cd3d7d70260a64c6
This commit is contained in:
@@ -120,7 +120,7 @@ class ClientTestBase(tempest.test.BaseTestCase):
|
||||
cmd = ' '.join([os.path.join(CONF.cli.cli_dir, cmd),
|
||||
flags, action, params])
|
||||
LOG.info("running: '%s'" % cmd)
|
||||
cmd = shlex.split(cmd)
|
||||
cmd = shlex.split(cmd.encode('utf-8'))
|
||||
result = ''
|
||||
result_err = ''
|
||||
stdout = subprocess.PIPE
|
||||
|
||||
@@ -25,7 +25,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def sudo_cmd_call(cmd):
|
||||
args = shlex.split(cmd)
|
||||
args = shlex.split(cmd.encode('utf-8'))
|
||||
subprocess_args = {'stdout': subprocess.PIPE,
|
||||
'stderr': subprocess.STDOUT}
|
||||
proc = subprocess.Popen(['/usr/bin/sudo', '-n'] + args,
|
||||
@@ -84,7 +84,7 @@ def copy_file_to_host(file_from, dest, host, username, pkey):
|
||||
"-i %(pkey)s %(file1)s %(dest)s" % {'pkey': pkey,
|
||||
'file1': file_from,
|
||||
'dest': dest}
|
||||
args = shlex.split(cmd)
|
||||
args = shlex.split(cmd.encode('utf-8'))
|
||||
subprocess_args = {'stdout': subprocess.PIPE,
|
||||
'stderr': subprocess.STDOUT}
|
||||
proc = subprocess.Popen(args, **subprocess_args)
|
||||
|
||||
@@ -32,7 +32,7 @@ class StressFrameworkTest(base.TestCase):
|
||||
cmd = ' '.join([cmd, param])
|
||||
LOG.info("running: '%s'" % cmd)
|
||||
cmd_str = cmd
|
||||
cmd = shlex.split(cmd)
|
||||
cmd = shlex.split(cmd.encode('utf-8'))
|
||||
result = ''
|
||||
result_err = ''
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user