All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] utils: Use rm -rf in remove()
@ 2013-02-07 23:55 Richard Purdie
  2013-02-08  1:08 ` Chris Larson
  2013-02-08 13:47 ` Peter Kjellerstedt
  0 siblings, 2 replies; 7+ messages in thread
From: Richard Purdie @ 2013-02-07 23:55 UTC (permalink / raw)
  To: bitbake-devel

Whilst shutils.rmtree() is pythonic, its also slow. Its faster to
use rm -rf which makes optimal use of the right syscalls.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 484fb2d..94ef447 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -533,13 +533,15 @@ def remove(path, recurse=False):
     """Equivalent to rm -f or rm -rf"""
     if not path:
         return
-    import os, errno, shutil, glob
+    import os, errno, glob, subprocess
     for name in glob.glob(path):
         try:
             os.unlink(name)
         except OSError as exc:
             if recurse and exc.errno == errno.EISDIR:
-                shutil.rmtree(name)
+                # shutil.rmtree(name) would be ideal but its too slow
+                subprocess.call('rm -rf %s' % path, shell=True)
+                return
             elif exc.errno != errno.ENOENT:
                 raise
 





^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-02-16 15:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 23:55 [PATCH] utils: Use rm -rf in remove() Richard Purdie
2013-02-08  1:08 ` Chris Larson
2013-02-15 16:00   ` Richard Purdie
2013-02-16 13:51     ` Martin Ertsås
2013-02-16 14:54       ` Richard Purdie
2013-02-16 15:27         ` Martin Ertsås
2013-02-08 13:47 ` Peter Kjellerstedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.