You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clever/__init__.py
+22-21Lines changed: 22 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@
4
4
# Borrows heavily from the Python bindings for the Stripe API
5
5
6
6
# Imports
7
+
from __future__ importprint_function
7
8
importlogging
8
9
importos
9
10
importplatform
@@ -15,12 +16,12 @@
15
16
importtypes
16
17
importbase64
17
18
importpkg_resources
18
-
19
+
importsix
19
20
# Use cStringIO if ita's available. Otherwise, StringIO is fine.
20
21
try:
21
22
importcStringIOasStringIO
22
23
exceptImportError:
23
-
importStringIO
24
+
fromsiximportStringIO
24
25
25
26
# - Requests is the preferred HTTP library
26
27
# - Google App Engine has urlfetch
@@ -50,8 +51,8 @@
50
51
pass
51
52
else:
52
53
ifmajor==0and (minor<8or (minor==8andpatch<8)):
53
-
print>>sys.stderr, 'Warning: the Clever library requires that your Python "requests" library has a version no older than 0.8.8, but your "requests" library has version %s. Clever will fall back to an alternate HTTP library, so everything should work, though we recommend upgrading your "requests" library. If you have any questions, please contact [email protected]. (HINT: running "pip install -U requests" should upgrade your requests library to the latest version.)'% (
54
-
version, )
54
+
print('Warning: the Clever library requires that your Python "requests" library has a version no older than 0.8.8, but your "requests" library has version %s. Clever will fall back to an alternate HTTP library, so everything should work, though we recommend upgrading your "requests" library. If you have any questions, please contact [email protected]. (HINT: running "pip install -U requests" should upgrade your requests library to the latest version.)'% (
55
+
version, ), file=sys.stderr)
55
56
_httplib=None
56
57
57
58
ifnot_httplib:
@@ -65,16 +66,16 @@
65
66
try:
66
67
importurllib2
67
68
_httplib='urllib2'
68
-
print>>sys.stderr, "Warning: the Clever library is falling back to urllib2 because pycurl isn't installed. urllib2's SSL implementation doesn't verify server certificates. For improved security, we suggest installing pycurl."
69
+
print("Warning: the Clever library is falling back to urllib2 because pycurl isn't installed. urllib2's SSL implementation doesn't verify server certificates. For improved security, we suggest installing pycurl.", file=sys.stderr)
69
70
exceptImportError:
70
71
pass
71
72
72
73
ifnot_httplib:
73
74
raiseImportError(
74
75
"Clever requires one of pycurl, Google App Engine's urlfetch, or urllib2. If you are on a platform where none of these libraries are available, please let us know at [email protected].")
'Warning: It looks like your installed version of the "requests" library is not compatible with Clever\'s usage thereof. (HINT: The most likely cause is that your "requests" library is out of date. You can fix that by running "pip install -U requests".) The underlying error was: %s'% (e, ))
0 commit comments