[molecule] rewrite molecule.utils.exec_cmd() to not use shell=True

The following changes were required code-wide:
- use shlex.split() to split commands read from spec files
- use glob.glob() where required
- write command splitter function and make use of it instead of
  simple string splitter
This commit is contained in:
Fabio Erculiani
2011-09-04 11:52:02 +02:00
parent 27f918ab3b
commit 7ecd318eef
2 changed files with 8 additions and 4 deletions
+7 -1
View File
@@ -17,7 +17,9 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import os
from molecule.compat import convert_to_unicode
import shlex
from molecule.compat import convert_to_unicode, convert_to_rawstring
import molecule.utils
class GenericSpecFunctions(object):
@@ -53,6 +55,10 @@ class GenericSpecFunctions(object):
def ve_string_splitter(self, x):
return convert_to_unicode(x).strip().split()
def ve_command_splitter(self, x):
return [convert_to_unicode(y) for y in \
shlex.split(convert_to_rawstring(x))]
def ve_integer_converter(self, x):
return int(x)
+1 -3
View File
@@ -78,9 +78,7 @@ def is_exec_available(exec_name):
return False
def exec_cmd(args, env = None):
# do not use Popen otherwise it will try to replace
# wildcards automatically ==> rsync no workie
return subprocess.call(' '.join(args), shell = True, env = env)
return subprocess.call(args, env = env)
def exec_cmd_get_status_output(args):
"""Return (status, output) of executing cmd in a shell."""