diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-03 16:51:34 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-15 15:53:26 +0000 |
commit | 96088ebdec08e49ba9e8dbcac437bfcdc21f5983 (patch) | |
tree | cf49420ee9bf355913213139f4e1af7f953aec51 | |
parent | 4eb3b6bb9f936808ddf085624078f6479c522c48 (diff) | |
download | bitbake-96088ebdec08e49ba9e8dbcac437bfcdc21f5983.tar.gz |
utils: Use rm -rf in remove()
Whilst shutils.rmtree() is pythonic, its also slow. Its faster to
use rm -rf which makes optimial use of the right syscalls.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/utils.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py index b1a0f25e7..8c363dfe2 100644 --- a/lib/bb/utils.py +++ b/lib/bb/utils.py @@ -535,14 +535,17 @@ def remove(path, recurse=False): """Equivalent to rm -f or rm -rf""" if not path: return - import os, errno, shutil, glob + if recurse: + import subprocess + # shutil.rmtree(name) would be ideal but its too slow + subprocess.call("rm -rf %s" % path, shell=True) + return + import os, errno, glob for name in glob.glob(path): try: os.unlink(name) except OSError as exc: - if recurse and exc.errno == errno.EISDIR: - shutil.rmtree(name) - elif exc.errno != errno.ENOENT: + if exc.errno != errno.ENOENT: raise def prunedir(topdir): |