summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Utils.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-03-14 13:05:08 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-03-14 13:05:08 -0400
commit3d06f311274d6b942ee89d8cdb13b2ecc99af1b0 (patch)
treebc3d6403e053f0e30f525c6555bd00dd0d0c973e /src/lib/Bcfg2/Utils.py
parentacb1dde9ba48b04d1ceb701ce849e96cef3d0070 (diff)
downloadbcfg2-3d06f311274d6b942ee89d8cdb13b2ecc99af1b0.tar.gz
bcfg2-3d06f311274d6b942ee89d8cdb13b2ecc99af1b0.tar.bz2
bcfg2-3d06f311274d6b942ee89d8cdb13b2ecc99af1b0.zip
use Executor class for better subprocess calling on server
Diffstat (limited to 'src/lib/Bcfg2/Utils.py')
-rw-r--r--src/lib/Bcfg2/Utils.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lib/Bcfg2/Utils.py b/src/lib/Bcfg2/Utils.py
index 3b1559528..29c27257a 100644
--- a/src/lib/Bcfg2/Utils.py
+++ b/src/lib/Bcfg2/Utils.py
@@ -183,9 +183,10 @@ class Executor(object):
return _timeout
- def run(self, command, inputdata=None, shell=False, timeout=None):
+ def run(self, command, inputdata=None, timeout=None, **kwargs):
""" Run a command, given as a list, optionally giving it the
- specified input data.
+ specified input data. All additional keyword arguments are
+ passed through to :class:`subprocess.Popen`.
:param command: The command to run, as a list (preferred) or
as a string. See :class:`subprocess.Popen` for
@@ -193,8 +194,6 @@ class Executor(object):
:type command: list or string
:param inputdata: Data to pass to the command on stdin
:type inputdata: string
- :param shell: Run the given command in a shell (not recommended)
- :type shell: bool
:param timeout: Kill the command if it runs longer than this
many seconds. Set to 0 or -1 to explicitly
override a default timeout.
@@ -206,9 +205,11 @@ class Executor(object):
else:
cmdstr = " ".join(command)
self.logger.debug("Running: %s" % cmdstr)
- proc = subprocess.Popen(command, shell=shell, bufsize=16384,
- stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, close_fds=True)
+ args = dict(shell=False, bufsize=16384, close_fds=True)
+ args.update(kwargs)
+ args.update(stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ proc = subprocess.Popen(command, **args)
if timeout is None:
timeout = self.timeout
if timeout is not None: