summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-03 16:51:34 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-15 15:53:41 +0000
commitf7836b129954244937d5d20c090fb9c5a7e9f61d (patch)
treee450b2a26de553a4cd5a5625340f15bff54cecdf
parent5da2485717b1a32c7a880e500a4251c67ef713ea (diff)
downloadpoky-f7836b129954244937d5d20c090fb9c5a7e9f61d.tar.gz
bitbake: 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. (Bitbake rev: 96088ebdec08e49ba9e8dbcac437bfcdc21f5983) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/utils.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index b1a0f25e75..8c363dfe20 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -535,14 +535,17 @@ def remove(path, recurse=False):
535 """Equivalent to rm -f or rm -rf""" 535 """Equivalent to rm -f or rm -rf"""
536 if not path: 536 if not path:
537 return 537 return
538 import os, errno, shutil, glob 538 if recurse:
539 import subprocess
540 # shutil.rmtree(name) would be ideal but its too slow
541 subprocess.call("rm -rf %s" % path, shell=True)
542 return
543 import os, errno, glob
539 for name in glob.glob(path): 544 for name in glob.glob(path):
540 try: 545 try:
541 os.unlink(name) 546 os.unlink(name)
542 except OSError as exc: 547 except OSError as exc:
543 if recurse and exc.errno == errno.EISDIR: 548 if exc.errno != errno.ENOENT:
544 shutil.rmtree(name)
545 elif exc.errno != errno.ENOENT:
546 raise 549 raise
547 550
548def prunedir(topdir): 551def prunedir(topdir):