libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1240455 - in /libcloud/trunk: CHANGES libcloud/common/base.py
Date Sat, 04 Feb 2012 05:29:00 GMT
Author: tomaz
Date: Sat Feb  4 05:29:00 2012
New Revision: 1240455

URL: http://svn.apache.org/viewvc?rev=1240455&view=rev
Log:
Fix debug mode so it works with Python 3.

Modified:
    libcloud/trunk/CHANGES
    libcloud/trunk/libcloud/common/base.py

Modified: libcloud/trunk/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/trunk/CHANGES?rev=1240455&r1=1240454&r2=1240455&view=diff
==============================================================================
--- libcloud/trunk/CHANGES (original)
+++ libcloud/trunk/CHANGES Sat Feb  4 05:29:00 2012
@@ -13,6 +13,9 @@ Changes with Apache Libcloud in developm
        "Accept-Encoding" "gzip,deflate" header with all the requests.
        [Tomaz Muraus]
 
+     - Fix debug module (LIBCLOUD_DEBUG env variable) so it works with Python 3
+       [Tomaz Muraus]
+
   *) Compute:
 
      - Added support for retrieving OpenNebula v3.2 instance types, OpenNebula

Modified: libcloud/trunk/libcloud/common/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/base.py?rev=1240455&r1=1240454&r2=1240455&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/base.py (original)
+++ libcloud/trunk/libcloud/common/base.py Sat Feb  4 05:29:00 2012
@@ -33,6 +33,7 @@ from libcloud.utils.py3 import httplib
 from libcloud.utils.py3 import urlparse
 from libcloud.utils.py3 import urlencode
 from libcloud.utils.py3 import StringIO
+from libcloud.utils.py3 import u
 from libcloud.utils.py3 import b
 
 from libcloud.utils.misc import lowercase_keys
@@ -240,8 +241,14 @@ class LoggingConnection():
             def __init__(self, s):
                 self.s = s
 
-            def makefile(self, mode, foo):
-                return StringIO(self.s)
+            def makefile(self, *args, **kwargs):
+                if PY3:
+                    from io import BytesIO
+                    cls = BytesIO
+                else:
+                    cls = StringIO
+
+                return cls(b(self.s))
         rr = r
         original_data = body
         headers = lowercase_keys(dict(r.getheaders()))
@@ -253,13 +260,14 @@ class LoggingConnection():
         elif encoding in ['gzip', 'x-gzip']:
             body = decompress_data('gzip', body)
 
+
         if r.chunked:
             ht += "%x\r\n" % (len(body))
-            ht += body
+            ht += u(body)
             ht += "\r\n0\r\n"
         else:
-            ht += body
-        rr = httplib.HTTPResponse(fakesock(ht),
+            ht += u(body)
+        rr = httplib.HTTPResponse(sock=fakesock(ht),
                                   method=r._method,
                                   debuglevel=r.debuglevel)
         rr.begin()



Mime
View raw message