[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Handle GPGME errors better in the EmailServer.
commit fe43555b261f37660bb02d31ca4f5dfaf9668197
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Tue Oct 29 05:45:28 2013 +0000
Handle GPGME errors better in the EmailServer.
* CHANGE getGPGContext() function to output at least some useful information
when it encounters an error, rather than just spewing 'Unusable GPG Key'
without any context.
---
lib/bridgedb/EmailServer.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/bridgedb/EmailServer.py b/lib/bridgedb/EmailServer.py
index 23fc8c1..1ee27c0 100644
--- a/lib/bridgedb/EmailServer.py
+++ b/lib/bridgedb/EmailServer.py
@@ -465,8 +465,13 @@ def getGPGContext(cfg):
# make sure we can sign
message = StringIO('Test')
signature = StringIO()
- new_sigs = ctx.sign(message, signature, gpgme.SIG_MODE_CLEAR)
- assert len(new_sigs) == 1
+ try:
+ new_sigs = ctx.sign(message, signature, gpgme.SIG_MODE_CLEAR)
+ except gpgme.GpgmeError as error:
+ logging.error(error.message)
+ return None
+
+ assert len(new_sigs) == 1, "Testing signature creation failed"
# return the ctx
return ctx
@@ -474,6 +479,7 @@ def getGPGContext(cfg):
except IOError, e:
# exit noisily if keyfile not found
exit(e)
- except AssertionError:
+ except AssertionError as error:
+ logging.error(error.message)
# exit noisily if key does not pass tests
exit('Invalid GPG Signing Key')
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits