Merge branch 'develop' of git://github.com/foxx/salt into foxx-develop

Conflicts:
	salt/utils/timed_subprocess.py
This commit is contained in:
Thomas S Hatch 2013-08-26 11:36:45 -06:00
commit 69e96a1976
2 changed files with 17 additions and 6 deletions

View file

@ -169,7 +169,8 @@ def _run(cmd,
rstrip=True,
template=None,
umask=None,
timeout=None):
timeout=None,
with_communicate=True):
'''
Do the DRY thing and only call subprocess.Popen() once
'''
@ -294,7 +295,8 @@ def _run(cmd,
'env': run_env,
'stdin': str(stdin) if stdin is not None else stdin,
'stdout': stdout,
'stderr': stderr}
'stderr': stderr,
'with_communicate' : with_communicate}
if umask:
try:
@ -705,7 +707,8 @@ def retcode(cmd,
template=template,
umask=umask,
quiet=quiet,
timeout=timeout)['retcode']
timeout=timeout,
with_communicate=False)['retcode']
def script(

View file

@ -17,7 +17,12 @@ class TimedProc(object):
# Translate a newline submitted as '\n' on the CLI to an actual
# newline character.
self.stdin = self.stdin.replace('\\n', '\n')
self.process = subprocess.Popen(args, stdin=subprocess.PIPE, **kwargs)
self.with_communicate = True
if 'with_communicate' in kwargs:
self.with_communicate = kwargs['with_communicate']
del kwargs['with_communicate']
self.process = subprocess.Popen(args, **kwargs)
def wait(self, timeout=None):
'''
@ -25,8 +30,11 @@ class TimedProc(object):
If timeout is reached, throw TimedProcTimeoutError
'''
def receive():
(self.stdout, self.stderr) = \
self.process.communicate(input=self.stdin)
if self.with_communicate:
(self.stdout, self.stderr) = self.process.communicate(input=self.stdin)
else:
self.process.wait()
(self.stdout, self.stderr) = (None, None)
if timeout:
if not isinstance(timeout, (int, float)):