From d42d6af12bf029a7f07703a44883a8326b7c5e57 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Sat, 22 Oct 2005 06:35:57 +0000 Subject: [PATCH] [project @ Arch-1:robey@lag.net--2005-master-shake%paramiko--dev--1--patch-68] set errno for some errors --- paramiko/sftp_client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py index 06e402e..fd76207 100644 --- a/paramiko/sftp_client.py +++ b/paramiko/sftp_client.py @@ -20,6 +20,7 @@ Client-mode SFTP support. """ +import errno import os from paramiko.sftp import * from paramiko.sftp_attr import SFTPAttributes @@ -56,6 +57,7 @@ class SFTPClient (BaseSFTP): self.ultra_debug = False self.request_number = 1 self._cwd = None + # FIXME: after we require python 2.4, use set :) self._expecting = [] if type(sock) is Channel: # override default logger @@ -560,6 +562,11 @@ class SFTPClient (BaseSFTP): return elif code == SFTP_EOF: raise EOFError(text) + elif code == SFTP_NO_SUCH_FILE: + # clever idea from john a. meinel: map the error codes to errno + raise IOError(errno.ENOENT, text) + elif code == SFTP_PERMISSION_DENIED: + raise IOError(errno.EACCES, text) else: raise IOError(text)