cubicweb/web/webctl.py
branch3.25
changeset 12140 20035170160c
parent 11767 432f87a63057
child 12159 8a1306c43656
--- a/cubicweb/web/webctl.py	Mon Apr 03 14:43:44 2017 +0200
+++ b/cubicweb/web/webctl.py	Tue Apr 04 11:41:23 2017 +0200
@@ -39,6 +39,17 @@
     from shutil import copytree as linkdir
 
 
+def rmtreecontent(dst):
+    """Delete the content of the dst directory (but NOT the directory
+       itself)"""
+    for fname in os.listdir(dst):
+        fpath = osp.join(dst, fname)
+        if osp.isfile(fpath):
+            os.unlink(fpath)
+        else:
+            rmtree(fpath)
+
+
 class WebCreateHandler(CommandHandler):
     cmdname = 'create'
 
@@ -70,7 +81,7 @@
                      ASK.confirm('Remove existing data directory %s?' % dest))):
                 raise ExecutionError('Directory %s already exists. '
                                      'Remove it first.' % dest)
-            rmtree(dest)
+            rmtreecontent(dest)
         config.quick_start = True # notify this is not a regular start
         # list all resources (no matter their order)
         resources = set()