Please review the attached patch.

-- jerome
From b1cc212bcfc4903c70f1150d83b3b376cee19fdf Mon Sep 17 00:00:00 2001
From: Jerome Charaoui <jer...@riseup.net>
Date: Tue, 19 Jul 2016 15:01:45 -0400
Subject: [PATCH] Ignore irrelevant gpg errors (closes #736548)

This will allow the expect_pattern() to skip gpg
errors which are not useful: KEYEXPIRED, SIGEXPIRED
and "gpg: moving a key signature to the correct place"

For descriptions of these errors, see GnuPG
documentation in doc/DETAILS
---
 monkeysign/gpg.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/monkeysign/gpg.py b/monkeysign/gpg.py
index 456cf3b..bc5661f 100644
--- a/monkeysign/gpg.py
+++ b/monkeysign/gpg.py
@@ -224,8 +224,17 @@ class Context():
 
         this therefore looks only at the next line, but may also hang
         like seek_pattern()
+
+        if the beginning of the line matches a pattern which is
+        being ignored, it will skip it and look at the next line
         """
         line = fd.readline()
+        ignored = ('[GNUPG:] KEYEXPIRED', '[GNUPG:] SIGEXPIRED', 'gpg: ')
+
+        while line and line.startswith(ignored):
+            if self.debug: print >>self.debug, "SKIPPED:", line,
+            line = fd.readline()
+
         match = re.search(pattern, line)
 
         if self.debug:
@@ -469,15 +478,6 @@ class Keyring():
         except GpgProtocolError as e:
             if 'sign_uid.okay' in str(e):
                 multiuid = False
-            elif '[GNUPG:]' not in str(e):
-                # this is not a protocol message, try again but skipping now
-                # this was necessary in order to sign Zack's key, as it was spewing:
-                # gpg: moving a key signature to the correct place
-                # instead of a [GNUGPG:] message
-                try:
-                    multiuid = self.context.seek(proc.stderr, 'GET_BOOL keyedit.sign_all.okay')
-                except GpgProtocolError as e:
-                    raise GpgRuntimeError(self.context.returncode, _('cannot select uid for signing: %s') % e.found().decode('utf-8'))
             else:
                 raise GpgRuntimeError(self.context.returncode, _('cannot select uid for signing: %s') % e.found().decode('utf-8'))
         if multiuid:
-- 
2.8.1

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to