Skip to content

Instantly share code, notes, and snippets.

@humanthe
humanthe / ftprmtree.py
Created October 17, 2016 15:35 — forked from artlogic/ftprmtree.py
Python ftplib rmtree
def FtpRmTree(ftp, path):
"""Recursively delete a directory tree on a remote server."""
wd = ftp.pwd()
try:
names = ftp.nlst(path)
except ftplib.all_errors as e:
# some FTP servers complain when you try and list non-existent paths
_log.debug('FtpRmTree: Could not remove {0}: {1}'.format(path, e))
return