summaryrefslogtreecommitdiff
path: root/buildscripts/cleanbb.py
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-02-04 10:21:36 -0500
committerEliot Horowitz <eliot@10gen.com>2010-02-04 10:21:36 -0500
commitf8273464b7daa74ed4a06952eccc892fb14b0f05 (patch)
tree6e70eae6f110b31b0038b39f00fec7341af4168c /buildscripts/cleanbb.py
parenteffedd950de374a91ab415e66f405a2ae4a3885b (diff)
downloadmongo-f8273464b7daa74ed4a06952eccc892fb14b0f05.tar.gz
bb files
Diffstat (limited to 'buildscripts/cleanbb.py')
-rw-r--r--buildscripts/cleanbb.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/buildscripts/cleanbb.py b/buildscripts/cleanbb.py
new file mode 100644
index 00000000000..68a80127525
--- /dev/null
+++ b/buildscripts/cleanbb.py
@@ -0,0 +1,43 @@
+
+import sys
+import os
+import utils
+import time
+
+def killprocs( signal="" ):
+ cwd = os.getcwd();
+ if cwd.find("buildscripts" ) > 0 :
+ cwd = cwd.partition( "buildscripts" )[0]
+
+ killed = 0
+
+ for x in utils.getprocesslist():
+ x = x.lstrip()
+ if x.find( cwd ) < 0:
+ continue
+
+ pid = x.partition( " " )[0]
+ print( "killing: " + x )
+ utils.execsys( "/bin/kill " + signal + " " + pid )
+ killed = killed + 1
+
+ return killed
+
+
+def cleanup( root ):
+
+ # delete all regular files, directories can stay
+ # NOTE: if we delete directories later, we can't delete diskfulltest
+ for ( dirpath , dirnames , filenames ) in os.walk( root , topdown=False ):
+ for x in filenames:
+ os.remove( dirpath + "/" + x )
+
+ if killprocs() > 0:
+ time.sleep(3)
+ killprocs("-9")
+
+if __name__ == "__main__":
+ root = "/data/db/"
+ if len( sys.argv ) > 1:
+ root = sys.argv[1]
+ cleanup( root )