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

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

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

The SFTP operations use pipelining for speed.

@param localpath: the local file to copy
@type localpath: str
@param remotepath: the destination path on the SFTP server
@type remotepath: str

@since: 1.4

Definition at line 460 of file sftp_client.py.

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


Generated by  Doxygen 1.6.0   Back to index