diff options
author | Robey Pointer <robey@lag.net> | 2004-12-09 04:15:12 +0000 |
---|---|---|
committer | Robey Pointer <robey@lag.net> | 2004-12-09 04:15:12 +0000 |
commit | ad87909720bf7e89cc5463c24d7c8fd6db58fc30 (patch) | |
tree | 1f51b15ebfef2f1cd6b881158f3d9619d8b6618b | |
parent | 0fa97ec147dabb46853f7265edf4501d100fd735 (diff) |
[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().
-rw-r--r-- | paramiko/sftp_file.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index f01d384d..612153b5 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 |