[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] Provide diagnostics for missing M2Crypto.



commit 9b04b5fe3d8aa8096737fa379183a311d46ffce8
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Tue Sep 18 21:27:45 2012 -0700

    Provide diagnostics for missing M2Crypto.
---
 flashproxy-reg-email |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/flashproxy-reg-email b/flashproxy-reg-email
index 424e731..a8f3130 100755
--- a/flashproxy-reg-email
+++ b/flashproxy-reg-email
@@ -10,7 +10,12 @@ import sys
 import tempfile
 
 from hashlib import sha1
-from M2Crypto import X509
+
+try:
+    from M2Crypto import X509
+except ImportError:
+    # Defer the error reporting so that --help works even without M2Crypto.
+    X509 = None
 
 DEFAULT_REMOTE_ADDRESS = ""
 DEFAULT_REMOTE_PORT = 9000
@@ -73,6 +78,8 @@ designated address. By default the remote address registered is
 Using an SMTP server or email address other than the defaults will not work
 unless you have made special arrangements to connect them to a facilitator.
 
+This program requires the M2Crypto library for Python.
+
   -d, --debug             enable debugging output (Python smtplib messages).
   -e, --email=ADDRESS     send mail to ADDRESS (default "%(email_addr)s").
   -h, --help              show this help.
@@ -159,6 +166,17 @@ else:
     usage(sys.stderr)
     sys.exit(1)
 
+if X509 is None:
+    print >> sys.stderr, """\
+This program requires the M2Crypto library, which is not installed.
+
+You can install it using one of the packages at
+http://chandlerproject.org/Projects/MeTooCrypto#Downloads.
+
+On Debian-like systems, use the command "apt-get install python-m2crypto".\
+"""
+    sys.exit(1)
+
 smtp = smtplib.SMTP(options.smtp_addr[0], options.smtp_addr[1], EHLO_FQDN)
 
 if options.debug:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits