comparison piecrust/commands/builtin/util.py @ 726:6e92b5cd0163

purge: Delete the whole cache directory, not just the current sub-cache.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 29 May 2016 22:18:50 -0700
parents 81d9c3a3a0b5
children 6db54bed2417
comparison
equal deleted inserted replaced
725:f1dd8f2e79e7 726:6e92b5cd0163
2 import os.path 2 import os.path
3 import shutil 3 import shutil
4 import codecs 4 import codecs
5 import logging 5 import logging
6 import yaml 6 import yaml
7 from piecrust import CACHE_DIR
7 from piecrust.app import CONFIG_PATH, THEME_CONFIG_PATH 8 from piecrust.app import CONFIG_PATH, THEME_CONFIG_PATH
8 from piecrust.commands.base import ChefCommand 9 from piecrust.commands.base import ChefCommand
9 10
10 11
11 logger = logging.getLogger(__name__) 12 logger = logging.getLogger(__name__)
61 62
62 def setupParser(self, parser, app): 63 def setupParser(self, parser, app):
63 pass 64 pass
64 65
65 def run(self, ctx): 66 def run(self, ctx):
66 cache_dir = ctx.app.cache_dir 67 cache_dir = os.path.join(ctx.app.root_dir, CACHE_DIR)
67 if cache_dir and os.path.isdir(cache_dir): 68 if cache_dir and os.path.isdir(cache_dir):
68 logger.info("Purging cache: %s" % cache_dir) 69 logger.info("Purging cache: %s" % cache_dir)
69 shutil.rmtree(cache_dir) 70 shutil.rmtree(cache_dir)
70 71
71 72