Use Popen.communicate instead of subprocess call
authorGuido Günther <agx@sigxcpu.org>
Mon, 29 Apr 2013 12:30:31 +0000 (14:30 +0200)
committerGuido Günther <agx@sigxcpu.org>
Mon, 29 Apr 2013 12:31:31 +0000 (14:31 +0200)
so we can caputure stderr and pass it along with any errors.

gbp/command_wrappers.py

index 47ad27b..8dba707 100644 (file)
@@ -50,6 +50,7 @@ class Command(object):
         else:
             self.env = None
 
+    # FIXME: should we make this similiar to __git_inout ?
     def __call(self, args):
         """
         Wraps subprocess.call so we can be verbose and fix python's
@@ -64,6 +65,12 @@ class Command(object):
         if self.shell:
             # subprocess.call only cares about the first argument if shell=True
             cmd = " ".join(cmd)
+        popen = subprocess.Popen(cmd,
+                                 cwd=self.cwd,
+                                 shell=self.shell,
+                                 preexec_fn=default_sigpipe,
+                                 stderr=subprocess.PIPE)
+        (dummy, stderr) = popen.communicate(input)
         return subprocess.call(cmd, cwd=self.cwd, shell=self.shell,
                                env=self.env, preexec_fn=default_sigpipe)