From patchwork Thu Jan 10 08:46:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [bitbake-devel] utils.py: Use shutil.rmtree if the path we wish to remove is a directory. Date: Thu, 10 Jan 2013 08:46:36 -0000 From: Martin Ertsaas X-Patchwork-Id: 42429 Message-Id: <1357807596-31587-1-git-send-email-martiert@gmail.com> To: bitbake-devel@lists.openembedded.org On mac, os.unlink does not remove directories, and we therefor have to explicitly use shutil.rmtree if the path is a directory. --- lib/bb/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/bb/utils.py b/lib/bb/utils.py index cef0fdd..8b6d3f5 100644 --- a/lib/bb/utils.py +++ b/lib/bb/utils.py @@ -561,7 +561,10 @@ def remove(path, recurse=False): import os, errno, shutil, glob for name in glob.glob(path): try: - os.unlink(name) + if os.path.isdir(name): + shutil.rmtree(name) + else: + os.unlink(name) except OSError as exc: if recurse and exc.errno == errno.EISDIR: shutil.rmtree(name)