Skip to contentSkip to conversation

crda: Throw verbose error message if M2Crypto is missing

PATCH Applied Michael Buesch 2 participants 2 messages Jan 18, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crda: Throw verbose error message if M2Crypto is missing

Instead of throwing a cryptic Python backtrace, throw a better error message, if the M2Crypto module is not installed.

---

utils/key2pub.py +7 -1
index 47f50e3..f8918fc 100755
@@ -1,7 +1,13 @@
 #!/usr/bin/env python
 
 import sys
-from M2Crypto import RSA
+try:
+	from M2Crypto import RSA
+except ImportError, e:
+	sys.stderr.write('ERROR: Failed to import the "M2Crypto" module: %s\n' % e.message)
+	sys.stderr.write('Please install the "M2Crypto" Python module.\n')
+	sys.stderr.write('On Debian GNU/Linux the package is called "python-m2crypto".\n')
+	sys.exit(1)
 
 def print_ssl(output, name, val):
     while val[0] == '\0':
Signature · 1 line
Greetings, Michael.