aboutsummaryrefslogtreecommitdiffstats
path: root/netlib
diff options
context:
space:
mode:
Diffstat (limited to 'netlib')
-rw-r--r--netlib/version_check.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/netlib/version_check.py b/netlib/version_check.py
index aae4e8c7..1d7e025c 100644
--- a/netlib/version_check.py
+++ b/netlib/version_check.py
@@ -3,10 +3,11 @@ Having installed a wrong version of pyOpenSSL or netlib is unfortunately a
very common source of error. Check before every start that both versions
are somewhat okay.
"""
-from __future__ import division, absolute_import, print_function, unicode_literals
+from __future__ import division, absolute_import, print_function
import sys
import inspect
import os.path
+
import OpenSSL
from . import version
@@ -28,19 +29,29 @@ def check_mitmproxy_version(mitmproxy_version, fp=sys.stderr):
def check_pyopenssl_version(min_version=PYOPENSSL_MIN_VERSION, fp=sys.stderr):
- v = tuple(int(x) for x in OpenSSL.__version__.split(".")[:2])
+ min_version_str = ".".join(str(x) for x in min_version)
+ try:
+ v = tuple(int(x) for x in OpenSSL.__version__.split(".")[:2])
+ except ValueError:
+ print(
+ "Cannot parse pyOpenSSL version: {}"
+ "mitmproxy requires pyOpenSSL {} or greater.".format(
+ OpenSSL.__version__, min_version_str
+ ),
+ file=fp
+ )
+ return
if v < min_version:
print(
- "You are using an outdated version of pyOpenSSL:"
- " mitmproxy requires pyOpenSSL %s or greater." %
- str(min_version),
+ "You are using an outdated version of pyOpenSSL: "
+ "mitmproxy requires pyOpenSSL {} or greater.".format(min_version_str),
file=fp
)
# Some users apparently have multiple versions of pyOpenSSL installed.
# Report which one we got.
pyopenssl_path = os.path.dirname(inspect.getfile(OpenSSL))
print(
- "Your pyOpenSSL %s installation is located at %s" % (
+ "Your pyOpenSSL {} installation is located at {}".format(
OpenSSL.__version__, pyopenssl_path
),
file=fp