From a9f52c4aff830ea8e3edc732ea139c8b3ad827e6 Mon Sep 17 00:00:00 2001 From: Sverre Johansen Date: Thu, 29 Jan 2009 23:09:08 +0530 Subject: [PATCH] Added support for returning output in local() as in sudo() and run() --- fabric.py | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fabric.py b/fabric.py index 34322bc..c491921 100644 --- a/fabric.py +++ b/fabric.py @@ -550,9 +550,11 @@ def local(cmd, **kwargs): # we don't need _escape_bash_specialchars for local execution final_cmd = _lazy_format(cmd) print("[localhost] run: " + final_cmd) - retcode = subprocess.call(final_cmd, shell=True) - if retcode != 0: + proc = subprocess.Popen(final_cmd, shell=True, stdout=subprocess.PIPE) + stdout = proc.communicate()[0] + if proc.returncode != 0: _fail(kwargs, "Local command failed:\n" + _indent(final_cmd)) + return stdout @operation def local_per_host(cmd, **kwargs): -- 1.6.1