[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master 08/10] daklib/gpg.py: capture stderr



Signed-off-by: Ansgar Burchardt <ansgar@debian.org>
---
 daklib/gpg.py |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/daklib/gpg.py b/daklib/gpg.py
index 5c396ec..90103af 100644
--- a/daklib/gpg.py
+++ b/daklib/gpg.py
@@ -86,30 +86,33 @@ class SignedFile(object):
         with _Pipe() as stdin:
          with _Pipe() as contents:
           with _Pipe() as status:
+           with _Pipe() as stderr:
             pid = os.fork()
             if pid == 0:
-                self._exec_gpg(stdin.r, contents.w, sys.stderr.fileno(), status.w)
+                self._exec_gpg(stdin.r, contents.w, stderr.w, status.w)
             else:
                 stdin.close_r()
                 contents.close_w()
+                stderr.close_w()
                 status.close_w()
 
-                read = self._do_io([contents.r, status.r], {stdin.w: data})
+                read = self._do_io([contents.r, stderr.r, status.r], {stdin.w: data})
                 stdin.w = None # was closed by _do_io
 
                 (pid_, exit_code, usage_) = os.wait4(pid, 0)
 
                 self.contents = read[contents.r]
                 self.status   = read[status.r]
+                self.stderr   = read[stderr.r]
 
                 if self.status == "":
-                    raise GpgException("No status output from GPG. (GPG exited with status code %s)" % exit_code)
+                    raise GpgException("No status output from GPG. (GPG exited with status code %s)\n%s" % (exit_code, self.stderr))
 
                 for line in self.status.splitlines():
                     self._parse_status(line)
 
                 if require_signature and not self.valid:
-                    raise GpgException("No valid signature found. (GPG exited with status code %s)" % exit_code)
+                    raise GpgException("No valid signature found. (GPG exited with status code %s)\n%s" % (exit_code, self.stderr))
 
     def _do_io(self, read, write):
         read_lines = dict( (fd, []) for fd in read )
-- 
1.7.2.5



Reply to: