cubicweb/web/webctl.py
branch3.25
changeset 12140 20035170160c
parent 11767 432f87a63057
child 12159 8a1306c43656
equal deleted inserted replaced
12139:b5be819872bb 12140:20035170160c
    37     from os import symlink as linkdir
    37     from os import symlink as linkdir
    38 except ImportError:
    38 except ImportError:
    39     from shutil import copytree as linkdir
    39     from shutil import copytree as linkdir
    40 
    40 
    41 
    41 
       
    42 def rmtreecontent(dst):
       
    43     """Delete the content of the dst directory (but NOT the directory
       
    44        itself)"""
       
    45     for fname in os.listdir(dst):
       
    46         fpath = osp.join(dst, fname)
       
    47         if osp.isfile(fpath):
       
    48             os.unlink(fpath)
       
    49         else:
       
    50             rmtree(fpath)
       
    51 
       
    52 
    42 class WebCreateHandler(CommandHandler):
    53 class WebCreateHandler(CommandHandler):
    43     cmdname = 'create'
    54     cmdname = 'create'
    44 
    55 
    45     def bootstrap(self, cubes, automatic=False, inputlevel=0):
    56     def bootstrap(self, cubes, automatic=False, inputlevel=0):
    46         """bootstrap this configuration"""
    57         """bootstrap this configuration"""
    68             if (not ask_clean or
    79             if (not ask_clean or
    69                 not (config.verbosity and
    80                 not (config.verbosity and
    70                      ASK.confirm('Remove existing data directory %s?' % dest))):
    81                      ASK.confirm('Remove existing data directory %s?' % dest))):
    71                 raise ExecutionError('Directory %s already exists. '
    82                 raise ExecutionError('Directory %s already exists. '
    72                                      'Remove it first.' % dest)
    83                                      'Remove it first.' % dest)
    73             rmtree(dest)
    84             rmtreecontent(dest)
    74         config.quick_start = True # notify this is not a regular start
    85         config.quick_start = True # notify this is not a regular start
    75         # list all resources (no matter their order)
    86         # list all resources (no matter their order)
    76         resources = set()
    87         resources = set()
    77         for datadir in self._datadirs(config, repo=repo):
    88         for datadir in self._datadirs(config, repo=repo):
    78             for dirpath, dirnames, filenames in os.walk(datadir):
    89             for dirpath, dirnames, filenames in os.walk(datadir):