[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fab-user] [PATCH] BUG: SFTP exception with strerror = None

From: Evan Jones
Subject: [Fab-user] [PATCH] BUG: SFTP exception with strerror = None
Date: Mon, 25 May 2009 11:29:35 -0400
User-agent: Thunderbird (X11/20090318)

I ran into a case where paramiko's SFTP client throws an exception with .strerror set to None. I am uploading a file to the remote server. The file is in use on the remote server, as it is a binary being executed. The GIT version of Fabric raises the following exception:

Traceback (most recent call last):
  File "/home/evanj/fabric/fabric/main.py", line 428, in main
    commands[name](*args, **kwargs)
File "/home/evanj/fabric/fabric/decorators.py", line 26, in inner_decorator
    return func(*args, **kwargs)
  File "/home/evanj/fabtest/fabfile.py", line 51, in deploy
  File "/home/evanj/fabtest/fabfile.py", line 44, in startBackups
    put("./htableserver", "htableserver")
File "/home/evanj/fabric/fabric/network.py", line 364, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/home/evanj/fabric/fabric/operations.py", line 292, in put
    _handle_failure(message=msg % lpath, exception=e)
File "/home/evanj/fabric/fabric/operations.py", line 42, in _handle_failure
  File "/home/evanj/fabric/fabric/utils.py", line 48, in indent
    text = '\n'.join(text)

The attached patch changes the output to the following:

Fatal error: put() encountered an exception while uploading './htableserver'

Underlying exception message:


For more information, in this situation the OpenSSH SFTP client reports:

sftp> put htableserver
Uploading htableserver to /home/evanj/htableserver
Couldn't get handle: Failure

Using the GIT version of paramiko directly, the exception is:

Traceback (most recent call last):
  File "../fabtest/bug.py", line 24, in <module>
    sftp.put(local_path, remote_path)
  File "/home/evanj/paramiko/paramiko/sftp_client.py", line 549, in put
    fr = self.file(remotepath, 'wb')
  File "/home/evanj/paramiko/paramiko/sftp_client.py", line 240, in open
    t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
File "/home/evanj/paramiko/paramiko/sftp_client.py", line 609, in _request
    return self._read_response(num)
File "/home/evanj/paramiko/paramiko/sftp_client.py", line 656, in _read_response
File "/home/evanj/paramiko/paramiko/sftp_client.py", line 686, in _convert_status
    raise IOError(text)
IOError: Failure

Evan Jones

Evan Jones
>From d65b5d84b8609d01376dd6240cc1d99f70ea7d3f Mon Sep 17 00:00:00 2001
From: Evan Jones <address@hidden>
Date: Mon, 25 May 2009 11:28:56 -0400
Subject: [PATCH] Handle exceptions where .strerror is None.

 fabric/operations.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fabric/operations.py b/fabric/operations.py
index dde606a..7fb18f4 100644
--- a/fabric/operations.py
+++ b/fabric/operations.py
@@ -33,7 +33,7 @@ def _handle_failure(message, exception=None):
         # subclasses, for example, "are" integers and .strerror is the string.
         # Others "are" strings themselves. May have to expand this further for
         # other error types.
-        if hasattr(exception, 'strerror'):
+        if hasattr(exception, 'strerror') and exception.strerror is not None:
             underlying_msg = exception.strerror
             underlying_msg = exception

reply via email to

[Prev in Thread] Current Thread [Next in Thread]