SFTP

class keg_storage.backends.sftp.SFTPRemoteFile(mode, path, client)[source]
close()[source]

Cleanup and deallocate any held resources. This method may be called multiple times on a single instance. If the file was already closed, this method should do nothing.

read(size: int)[source]

Read and return up to size bytes from the remote file. If the end of the file is reached this should return an empty bytes string.

write(data: bytes)[source]

Write the data buffer to the remote file.

class keg_storage.backends.sftp.SFTPStorage(host, username, key_filename, known_hosts_fpath, allow_agent=False, look_for_keys=False, name='sftp')[source]
delete(path: str)[source]

Delete the remote file specified by path.

list(path: str)[source]

Returns a list of ListEntry`s representing files available under the directory or prefix given in `path.

open(path: str, mode: Union[keg_storage.backends.base.FileMode, str])[source]

Returns a instance of RemoteFile for the given path that can be used for reading and/or writing depending on the mode given.