From ad87909720bf7e89cc5463c24d7c8fd6db58fc30 Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Thu, 9 Dec 2004 04:15:12 +0000 Subject: [PATCH] [project @ Arch-1:robey@lag.net--2003-public%secsh--dev--1.0--patch-118] fix SFTPFile gettimeout/settimeout i don't think the gettimeout/settimeout calls on SFTPFile ever worked. also, simplify the implementation of _get_size() since it's nearly identical to stat(). --- paramiko/sftp_file.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index f01d384..612153b 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -73,7 +73,7 @@ class SFTPFile (BufferedFile): before raising C{socket.timeout}, or C{None} for no timeout @type timeout: float """ - self.sock.settimeout(timeout) + self.sftp.sock.settimeout(timeout) def gettimeout(self): """ @@ -83,7 +83,7 @@ class SFTPFile (BufferedFile): @see: L{Channel.gettimeout} @rtype: float """ - return self.sock.gettimeout() + return self.sftp.sock.gettimeout() def setblocking(self, blocking): """ @@ -95,7 +95,7 @@ class SFTPFile (BufferedFile): mode. @type blocking: int """ - self.sock.setblocking(blocking) + self.sftp.sock.setblocking(blocking) def seek(self, offset, whence=0): self.flush() @@ -127,11 +127,7 @@ class SFTPFile (BufferedFile): def _get_size(self): - t, msg = self.sftp._request(CMD_FSTAT, self.handle) - if t != CMD_ATTRS: - raise SFTPError('Expected attrs') - attr = SFTPAttributes._from_msg(msg) try: - return attr.st_size + return self.stat().st_size except: return 0