1.1 --- a/MoinMessage.py Sat Oct 20 19:27:25 2012 +0200
1.2 +++ b/MoinMessage.py Sun Oct 21 00:43:40 2012 +0200
1.3 @@ -72,14 +72,23 @@
1.4
1.5 cmd = Popen(["gpg"] + self.conf_args + list(args), stdin=PIPE, stdout=PIPE, stderr=PIPE)
1.6
1.7 - if text:
1.8 - cmd.stdin.write(text)
1.9 - cmd.stdin.close()
1.10 + try:
1.11 + # Attempt to write input to the command and to read output from the
1.12 + # command.
1.13 +
1.14 + try:
1.15 + if text:
1.16 + cmd.stdin.write(text)
1.17 + cmd.stdin.close()
1.18
1.19 - self.errors = cmd.stderr.read()
1.20 + text = cmd.stdout.read()
1.21 +
1.22 + # I/O errors can indicate the failure of the command.
1.23
1.24 - try:
1.25 - text = cmd.stdout.read()
1.26 + except IOError:
1.27 + pass
1.28 +
1.29 + self.errors = cmd.stderr.read()
1.30
1.31 # Test for a zero result.
1.32
1.33 @@ -117,16 +126,24 @@
1.34
1.35 # Return the details of the signing key.
1.36
1.37 + identity = None
1.38 + fingerprint = None
1.39 +
1.40 for line in text.split("\n"):
1.41 try:
1.42 - prefix, msgtype, fingerprint, details = line.strip().split(" ", 3)
1.43 + prefix, msgtype, digest, details = line.strip().split(" ", 3)
1.44 except ValueError:
1.45 continue
1.46
1.47 # Return the fingerprint and identity details.
1.48
1.49 if msgtype == "GOODSIG":
1.50 - return fingerprint, details
1.51 + identity = details
1.52 + elif msgtype == "VALIDSIG":
1.53 + fingerprint = digest
1.54 +
1.55 + if identity and fingerprint:
1.56 + return fingerprint, identity
1.57
1.58 return None
1.59