libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject libcloud git commit: Fix LIBCLOUD_DEBUG mode - make sure it works correctly under Python 3.x.
Date Mon, 31 Aug 2015 22:38:46 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 1df5767ac -> d38712ee0


Fix LIBCLOUD_DEBUG mode - make sure it works correctly under Python 3.x.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/d38712ee
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d38712ee
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d38712ee

Branch: refs/heads/trunk
Commit: d38712ee0f0be8f84d2fde835f23ed08e5f5dc17
Parents: 1df5767
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Tue Sep 1 00:36:43 2015 +0200
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Tue Sep 1 00:38:15 2015 +0200

----------------------------------------------------------------------
 libcloud/__init__.py    | 16 +++++++++++++---
 libcloud/common/base.py |  4 ++--
 2 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/d38712ee/libcloud/__init__.py
----------------------------------------------------------------------
diff --git a/libcloud/__init__.py b/libcloud/__init__.py
index 725c3de..9ebb78f 100644
--- a/libcloud/__init__.py
+++ b/libcloud/__init__.py
@@ -55,12 +55,22 @@ def _init_once():
     This checks for the LIBCLOUD_DEBUG environment variable, which if it exists
     is where we will log debug information about the provider transports.
     """
+    from libcloud.utils.py3 import PY3
+
     path = os.getenv('LIBCLOUD_DEBUG')
     if path:
-        fo = codecs.open(path, 'a', encoding='utf8')
+        mode = 'a'
+
+        # Special case for /dev/stderr and /dev/stdout on Python 3.
+        # Opening those files in append mode will throw "illegal seek"
+        # exception there.
+        if path in ['/dev/stderr', '/dev/stdout'] and PY3:
+            mode = 'w'
+
+        fo = codecs.open(path, mode, encoding='utf8')
         enable_debug(fo)
 
-        if have_paramiko:
-            paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
+    if have_paramiko:
+        paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
 
 _init_once()

http://git-wip-us.apache.org/repos/asf/libcloud/blob/d38712ee/libcloud/common/base.py
----------------------------------------------------------------------
diff --git a/libcloud/common/base.py b/libcloud/common/base.py
index ac0fdd7..d4cbbae 100644
--- a/libcloud/common/base.py
+++ b/libcloud/common/base.py
@@ -313,7 +313,7 @@ class LoggingConnection():
         ht += "\r\n"
 
         # this is evil. laugh with me. ha arharhrhahahaha
-        class fakesock:
+        class fakesock(object):
             def __init__(self, s):
                 self.s = s
 
@@ -324,7 +324,7 @@ class LoggingConnection():
                 else:
                     cls = StringIO
 
-                return cls(self.s)
+                return cls(b(self.s))
         rr = r
         headers = lowercase_keys(dict(r.getheaders()))
 


Mime
View raw message