Mcsalgado's change to use shlex.quote instead of pipes.quote (#18534)

* Replace pipes.quote for shlex_quote

* More migration of pipes.quote to shlex_quote

Note that we cannot yet move module code over.  Modules have six-1.4
bundled which does not have shlex_quote.  This shouldn't be a problem as
the function is still importable from pipes.quote.  It's just that this
has become an implementation detail that makes us want to import from
shlex instead.

Once we get rid of the python2.4 dependency we can update to a newer
version of bundled six module-side and then we're free to use
shlex_quote everywhere.
This commit is contained in:
Toshio Kuratomi 2016-11-17 13:18:29 -08:00 committed by GitHub
parent 5d043b65d3
commit ed00741a01
16 changed files with 62 additions and 63 deletions

View file

@ -20,7 +20,6 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import pipes
import os
try:
@ -32,6 +31,7 @@ from nose.tools import eq_, raises
from ansible import constants as C
from ansible.compat.six import text_type
from ansible.compat.six.moves import shlex_quote
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import patch, MagicMock, mock_open
@ -164,7 +164,7 @@ class TestActionBase(unittest.TestCase):
# create a mock connection, so we don't actually try and connect to things
def env_prefix(**args):
return ' '.join(['%s=%s' % (k, pipes.quote(text_type(v))) for k,v in args.items()])
return ' '.join(['%s=%s' % (k, shlex_quote(text_type(v))) for k,v in args.items()])
mock_connection = MagicMock()
mock_connection._shell.env_prefix.side_effect = env_prefix