Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve httplib2 version check #174

Closed
sandrotosi opened this issue Dec 15, 2018 · 1 comment
Closed

Improve httplib2 version check #174

sandrotosi opened this issue Dec 15, 2018 · 1 comment

Comments

@sandrotosi
Copy link

Hello,
in Debian we applied this patch to detect httplib2 version more reliably:

--- a/pysimplesoap/transport.py
+++ b/pysimplesoap/transport.py
@@ -16,6 +16,8 @@
 import logging
 import ssl
 import sys
+from distutils.version import LooseVersion
+
 try:
     import urllib2
     from cookielib import CookieJar
@@ -62,7 +64,7 @@ class TransportBase:
 #
 try:
     import httplib2
-    if sys.version > '3' and httplib2.__version__ <= "0.7.7":
+    if sys.version > '3' and LooseVersion(httplib2.__version__) <= LooseVersion("0.7.7"):
         import http.client
         # httplib2 workaround: check_hostname needs a SSL context with either 
         #                      CERT_OPTIONAL or CERT_REQUIRED
@@ -92,9 +94,9 @@ else:
                 log.info("using proxy %s" % proxy)
 
             # set optional parameters according to supported httplib2 version
-            if httplib2.__version__ >= '0.3.0':
+            if LooseVersion(httplib2.__version__) >= LooseVersion('0.3.0'):
                 kwargs['timeout'] = timeout
-            if httplib2.__version__ >= '0.7.0':
+            if LooseVersion(httplib2.__version__) >= LooseVersion('0.7.0'):
                 kwargs['disable_ssl_certificate_validation'] = cacert is None
                 kwargs['ca_certs'] = cacert
             httplib2.Http.__init__(self, **kwargs)

would you consider applying it to pysimplesoap directly?

thanks!

@nmartensen
Copy link

Just for the record: this patch is identical to #170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants