From 235b4d340479a91a98e4089566f47eaefb69fa47 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Sun, 1 Sep 2013 22:15:09 -0500 Subject: Utils: Split commands given as strings Signed-off-by: Sol Jerome --- src/lib/Bcfg2/Utils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Utils.py b/src/lib/Bcfg2/Utils.py index 236f87d0a..10057b63e 100644 --- a/src/lib/Bcfg2/Utils.py +++ b/src/lib/Bcfg2/Utils.py @@ -2,12 +2,13 @@ used by both client and server. Stuff that doesn't fit anywhere else. """ +import fcntl +import logging import os import re -import sys -import fcntl import select -import logging +import shlex +import sys import subprocess import threading from Bcfg2.Compat import input, any # pylint: disable=W0622 @@ -216,12 +217,17 @@ class Executor(object): :type timeout: float :returns: :class:`Bcfg2.Utils.ExecutorResult` """ + shell = False + if 'shell' in kwargs: + shell = kwargs['shell'] if isinstance(command, str): cmdstr = command + if not shell: + command = shlex.split(cmdstr) else: cmdstr = " ".join(command) self.logger.debug("Running: %s" % cmdstr) - args = dict(shell=False, bufsize=16384, close_fds=True) + args = dict(shell=shell, bufsize=16384, close_fds=True) args.update(kwargs) args.update(stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) -- cgit v1.2.3-1-g7c22