diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2013-09-01 22:15:09 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2013-09-01 22:15:09 -0500 |
commit | 235b4d340479a91a98e4089566f47eaefb69fa47 (patch) | |
tree | 0b83aa03cb52bbc6ac0d8eb96e809473f7e08e00 /src | |
parent | 6b637011e1be7ff8cd67c208df8ae9ab28f11c4c (diff) | |
download | bcfg2-235b4d340479a91a98e4089566f47eaefb69fa47.tar.gz bcfg2-235b4d340479a91a98e4089566f47eaefb69fa47.tar.bz2 bcfg2-235b4d340479a91a98e4089566f47eaefb69fa47.zip |
Utils: Split commands given as strings
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Bcfg2/Utils.py | 14 |
1 files changed, 10 insertions, 4 deletions
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) |