Logo Search packages:      
Sourcecode: paramiko version File versions  Download package

def paramiko::sftp_client::SFTPClient::get (   self,
  remotepath,
  localpath 
)

Copy a remote file (C{remotepath}) from the SFTP server to the local
host as C{localpath}.  Any exception raised by operations will be
passed through.  This method is primarily provided as a convenience.

@param remotepath: the remote file to copy
@type remotepath: str
@param localpath: the destination path on the local host
@type localpath: str

@since: 1.4

Definition at line 491 of file sftp_client.py.

00491                                         :
        """
        Copy a remote file (C{remotepath}) from the SFTP server to the local
        host as C{localpath}.  Any exception raised by operations will be
        passed through.  This method is primarily provided as a convenience.
        
        @param remotepath: the remote file to copy
        @type remotepath: str
        @param localpath: the destination path on the local host
        @type localpath: str
        
        @since: 1.4
        """
        fr = self.file(remotepath, 'rb')
        fr.prefetch()
        fl = file(localpath, 'wb')
        size = 0
        while True:
            data = fr.read(32768)
            if len(data) == 0:
                break
            fl.write(data)
            size += len(data)
        fl.close()
        fr.close()
        s = os.stat(localpath)
        if s.st_size != size:
            raise IOError('size mismatch in get!  %d != %d' % (s.st_size, size))


    ###  internals...


Generated by  Doxygen 1.6.0   Back to index