summaryrefslogtreecommitdiff
blob: 8a77f250fb6fcf1513244166cca0051956cf3302 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
https://github.com/dae/anki/issues/1

--- libanki/anki/sync.py
+++ libanki/anki/sync.py
@@ -16,6 +16,15 @@
 HTTP_TIMEOUT = 30
 HTTP_PROXY = None
 
+try:
+    # httplib2 >=0.7.7
+    _proxy_info_from_environment = httplib2.proxy_info_from_environment
+    _proxy_info_from_url = httplib2.proxy_info_from_url
+except AttributeError:
+    # httplib2 <0.7.7
+    _proxy_info_from_environment = httplib2.ProxyInfo.from_environment
+    _proxy_info_from_url = httplib2.ProxyInfo.from_url
+
 # Httplib2 connection object
 ######################################################################
 
@@ -42,7 +51,7 @@
 def _setupProxy():
     global HTTP_PROXY
     # set in env?
-    p = httplib2.ProxyInfo.from_environment()
+    p = _proxy_info_from_environment()
     if not p:
         # platform-specific fetch
         url = None
@@ -59,7 +68,7 @@
             elif 'http' in r:
                 url = r['http']
         if url:
-            p = httplib2.ProxyInfo.from_url(url, _proxyMethod(url))
+            p = _proxy_info_from_url(url, _proxyMethod(url))
     HTTP_PROXY = p
 
 def _proxyMethod(url):