18 """cubicweb-ctl commands and command handlers common to twisted/modpython |
18 """cubicweb-ctl commands and command handlers common to twisted/modpython |
19 web configuration |
19 web configuration |
20 """ |
20 """ |
21 from __future__ import print_function |
21 from __future__ import print_function |
22 |
22 |
23 |
23 import os |
24 |
24 import os.path as osp |
25 import os, os.path as osp |
|
26 from shutil import copy, rmtree |
25 from shutil import copy, rmtree |
27 |
26 |
28 from logilab.common.shellutils import ASK |
27 from logilab.common.shellutils import ASK |
29 |
28 |
30 from cubicweb import ExecutionError |
29 from cubicweb import ExecutionError |
75 if not dest: |
74 if not dest: |
76 dest = config['staticdir-path'] |
75 dest = config['staticdir-path'] |
77 if not dest: |
76 if not dest: |
78 dest = osp.join(config.appdatahome, 'data') |
77 dest = osp.join(config.appdatahome, 'data') |
79 if osp.exists(dest): |
78 if osp.exists(dest): |
80 if config.verbosity and (not ask_clean or |
79 if (config.verbosity |
81 not (config.verbosity and |
80 and (not ask_clean |
82 ASK.confirm('Remove existing data directory %s?' % dest))): |
81 or not (config.verbosity |
|
82 and ASK.confirm('Remove existing data directory %s?' % dest)))): |
83 raise ExecutionError('Directory %s already exists. ' |
83 raise ExecutionError('Directory %s already exists. ' |
84 'Remove it first.' % dest) |
84 'Remove it first.' % dest) |
85 rmtreecontent(dest) |
85 rmtreecontent(dest) |
86 config.quick_start = True # notify this is not a regular start |
86 config.quick_start = True # notify this is not a regular start |
87 # list all resources (no matter their order) |
87 # list all resources (no matter their order) |
88 resources = set() |
88 resources = set() |
89 for datadir in self._datadirs(config, repo=repo): |
89 for datadir in self._datadirs(config, repo=repo): |
90 for dirpath, dirnames, filenames in os.walk(datadir): |
90 for dirpath, dirnames, filenames in os.walk(datadir): |
91 rel_dirpath = dirpath[len(datadir)+1:] |
91 rel_dirpath = dirpath[len(datadir) + 1:] |
92 resources.update(osp.join(rel_dirpath, f) for f in filenames) |
92 resources.update(osp.join(rel_dirpath, f) for f in filenames) |
93 |
93 |
94 # locate resources and copy them to destination |
94 # locate resources and copy them to destination |
95 for resource in resources: |
95 for resource in resources: |
96 dest_resource = osp.join(dest, resource) |
96 dest_resource = osp.join(dest, resource) |