From e299181a5dda25aed4879ebcbe1359604448b3ae Mon Sep 17 00:00:00 2001 From: "Jeremy T. Bouse" Date: Fri, 27 Nov 2009 16:25:55 -0500 Subject: Imported Upstream version 1.7.6 --- docs/paramiko.sftp_file-pysrc.html | 95 +++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 47 deletions(-) (limited to 'docs/paramiko.sftp_file-pysrc.html') diff --git a/docs/paramiko.sftp_file-pysrc.html b/docs/paramiko.sftp_file-pysrc.html index 5e9b4c7..86f8884 100644 --- a/docs/paramiko.sftp_file-pysrc.html +++ b/docs/paramiko.sftp_file-pysrc.html @@ -54,24 +54,24 @@

Source Code for Module paramiko.sftp_file

-  1  # Copyright (C) 2003-2007  Robey Pointer <robey@lag.net> 
-  2  # 
-  3  # This file is part of paramiko. 
-  4  # 
-  5  # Paramiko is free software; you can redistribute it and/or modify it under the 
-  6  # terms of the GNU Lesser General Public License as published by the Free 
-  7  # Software Foundation; either version 2.1 of the License, or (at your option) 
-  8  # any later version. 
-  9  # 
- 10  # Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY 
- 11  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 
- 12  # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
- 13  # details. 
- 14  # 
- 15  # You should have received a copy of the GNU Lesser General Public License 
- 16  # along with Paramiko; if not, write to the Free Software Foundation, Inc., 
- 17  # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. 
- 18   
+  1  # Copyright (C) 2003-2007  Robey Pointer <robeypointer@gmail.com> 
+  2  # 
+  3  # This file is part of paramiko. 
+  4  # 
+  5  # Paramiko is free software; you can redistribute it and/or modify it under the 
+  6  # terms of the GNU Lesser General Public License as published by the Free 
+  7  # Software Foundation; either version 2.1 of the License, or (at your option) 
+  8  # any later version. 
+  9  # 
+ 10  # Paramiko is distrubuted in the hope that it will be useful, but WITHOUT ANY 
+ 11  # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 
+ 12  # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
+ 13  # details. 
+ 14  # 
+ 15  # You should have received a copy of the GNU Lesser General Public License 
+ 16  # along with Paramiko; if not, write to the Free Software Foundation, Inc., 
+ 17  # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. 
+ 18   
  19  """ 
  20  L{SFTPFile} 
  21  """ 
@@ -94,11 +94,11 @@ paramiko.file" class="py-name" href="#" onclick="return doclink('link-5', 'file'
  37      """ 
  38   
  39      # Some sftp servers will choke if you send read/write requests larger than 
- 40      # this size. 
- 41      MAX_REQUEST_SIZE = 32768 
+ 40      # this size. 
+ 41      MAX_REQUEST_SIZE = 32768 
  42   
 
43 - def __init__(self, sftp, handle, mode='r', bufsize=-1): -
44 BufferedFile.__init__(self) 45 self.sftp = sftp @@ -159,13 +160,13 @@ paramiko.win_pageant.PageantConnection.__init__" class="py-name" href="#" onclic
60
61 - def _close(self, async=False):
62 # We allow double-close without signaling an error, because real - 63 # Python file objects do. However, we must protect against actually - 64 # sending multiple CMD_CLOSE packets, because after we close our - 65 # handle, the same handle may be re-allocated by the server, and we - 66 # may end up mysteriously closing some random other file. (This is - 67 # especially important because we unconditionally call close() from - 68 # __del__.) - 69 if self._closed: + 63 # Python file objects do. However, we must protect against actually + 64 # sending multiple CMD_CLOSE packets, because after we close our + 65 # handle, the same handle may be re-allocated by the server, and we + 66 # may end up mysteriously closing some random other file. (This is + 67 # especially important because we unconditionally call close() from + 68 # __del__.) + 69 if self._closed: 70 return 71 self.sftp._log( 75 try: 76 if async: 77 # GC'd file handle could be called from an arbitrary thread -- don't wait for a response - 78 self.sftp._async_request(type(None), 78 self.sftp._async_request(type(None), CMD_CLOSE, self.handle) 81 except EOFError: 82 # may have outlived the Transport connection - 83 pass + 83 pass 84 except (IOError, socket.error): 85 # may have outlived the Transport connection - 86 pass + 86 pass
87
88 - def _data_in_prefetch_requests(self, offset, size):
89 k = [i for i in self._prefetch_reads if i[0] <= offset] @@ -237,12 +238,12 @@ paramiko.rng_win32.error" class="py-name" href="#" onclick="return doclink('link 93 buf_offset, buf_size = k[-1] 94 if buf_offset + buf_size <= offset: 95 # prefetch request ends before this one begins - 96 return False + 96 return False 97 if buf_offset + buf_size >= offset + size: 98 # inclusive - 99 return True + 99 return True 100 # well, we have part of the request. see if another chunk has the rest. -101 return self._data_in_prefetch_requests(buf_offset + buf_size, offset + size - buf_offset - buf_size) +101 return self._data_in_prefetch_requests(buf_offset + buf_size, offset + size - buf_offset - buf_size)
102
103 - def _data_in_prefetch_buffers(self, offset):
104 """ @@ -258,7 +259,7 @@ paramiko.rng_win32.error" class="py-name" href="#" onclick="return doclink('link 114 buf_offset = offset - index 115 if buf_offset >= len(self._prefetch_data[index]): 116 # it's not here -117 return None +117 return None 118 return index
119
120 - def _read_prefetch(self, size): @@ -267,7 +268,7 @@ paramiko.rng_win32.error" class="py-name" href="#" onclick="return doclink('link 123 in the buffer, return None. otherwise, behaves like a normal read. 124 """ 125 # while not closed, and haven't fetched past the current position, and haven't reached EOF... -126 while True: +126 while True: 127 offset = self._data_in_prefetch_buffers(self._realpos) 128 if offset is not None: 129 break @@ -315,7 +316,7 @@ paramiko.sftp_si.CMD_DATA" class="py-name" href="#" onclick="return doclink('lin
159
160 - def _write(self, data):
161 # may write less than requested if it would exceed max packet size -162 chunk = min(len(data), self.MAX_REQUEST_SIZE) +162 chunk = min(len(data), self.MAX_REQUEST_SIZE) 163 req = self.sftp._async_request(type(None), CMD_STATUS: 167 raise SFTPError('Expected status') 168 # convert_status already called -169 return chunk +169 return chunk
170
171 - def settimeout(self, timeout):
172 """ @@ -682,7 +683,7 @@ paramiko.SFTPFile.stat paramiko.SFTPHandle.stat paramiko.SFTPServerInterface.stat" class="py-name" href="#" onclick="return doclink('link-90', 'stat', 'link-90');">stat().st_size 384 # queue up async reads for the rest of the file -385 chunks = [] +385 chunks = [] 386 n = self._realpos 387 while n < size: 388 chunk = min(self.MAX_REQUEST_SIZE, size - n) @@ -732,11 +733,11 @@ paramiko.util.DEBUG" class="py-name" href="#" onclick="return doclink('link-93', 411 read_chunks = [] 412 for offset, size in chunks: 413 # don't fetch data that's already in the prefetch buffer -414 if self._data_in_prefetch_buffers(offset) or self._data_in_prefetch_requests(offset, size): +414 if self._data_in_prefetch_buffers(offset) or self._data_in_prefetch_requests(offset, size): 415 continue 416 417 # break up anything larger than the max read size -418 while size > 0: +418 while size > 0: 419 chunk_size = min(size, self.MAX_REQUEST_SIZE) 420 read_chunks.append((offset, chunk_size)) 421 offset += chunk_size @@ -744,7 +745,7 @@ paramiko.util.DEBUG" class="py-name" href="#" onclick="return doclink('link-93', 423 424 self._start_prefetch(read_chunks) 425 # now we can just devolve to a bunch of read()s :) -426 for x in chunks: +426 for x in chunks: 427 self.seek(x[0]) 428 yield self.429 430 431 ### internals... -432 +432 433
434 - def _get_size(self):
435 try: @@ -775,8 +776,8 @@ paramiko.SFTPServerInterface.stat" class="py-name" href="#" onclick="return docl
448
449 - def _prefetch_thread(self, chunks):
450 # do these read requests in a temporary thread because there may be -451 # a lot of them, so it may block. -452 for offset, length in chunks: +451 # a lot of them, so it may block. +452 for offset, length in chunks: 453 self.sftp._async_request(self, CMD_STATUS: 457 # save exception and re-raise it on next file operation -458 try: +458 try: 459 self.sftp._convert_status(msg) 460 except Exception, x: 461 self._saved_exception = x @@ -852,7 +853,7 @@ expandto(location.href);