You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2021/10/25 10:47:25 UTC

[libcloud] 01/02: Add workaround for paramiko debug logging when LIBCLOUD_DEBUG is enabled.

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 4e2eaceee9d7a6051659c9320a10c241ffada1d8
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Mon Oct 25 12:11:29 2021 +0200

    Add workaround for paramiko debug logging when LIBCLOUD_DEBUG is
    enabled.
    
    Paramiko will always try to open file path in append mode which won't
    work with /dev/{stdout,stderr} on some distros so we simply ignore those
    errors for now.
---
 libcloud/__init__.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libcloud/__init__.py b/libcloud/__init__.py
index f9f1710..4e7f5e9 100644
--- a/libcloud/__init__.py
+++ b/libcloud/__init__.py
@@ -102,7 +102,14 @@ def _init_once():
 
         if have_paramiko and hasattr(paramiko.util, 'log_to_file'):
             import logging
-            paramiko.util.log_to_file(filename=path, level=logging.DEBUG)
+            # paramiko always tries to open file path in append mode which won't work with
+            # /dev/{stdout, stderr} so we just ignore those errors
+
+            try:
+                paramiko.util.log_to_file(filename=path, level=logging.DEBUG)
+            except OSError as e:
+                if "illegal seek" not in str(e).lower():
+                    raise e
 
     # check for broken `yum install python-requests`
     if have_requests and requests.__version__ == '2.6.0':