ftputil—a high-level FTP client library for Python
# Download some files from the login directory. with ftputil.FTPHost('ftp.domain.com', 'user', 'secret') as host: names = host.listdir(host.curdir) for name in names: if host.path.isfile(name): # remote name, local name, binary mode host.download(name, name, 'b') # Check if a remote text file contains "ftputil". # Stop reading as soon as the string is found. with host.file("some_file") as remote_fobj: for line in remote_fobj: if "ftputil" in line: found = True break else: found = False
See the documentation for all the features.