def set_up_cache_dir(): config_dir = _locate_config_dir() cache_dir = os.path.join(config_dir, "cache") if not os.path.exists(cache_dir): log.info("cache dir not found, so creating: %s", cache_dir) strif.make_all_dirs(cache_dir) return cache_dir
def _decompress_dir(archive_path, target_path, force=False): if os.path.exists(target_path): if force: log.info("deleting previous dir: %s", target_path) rmtree_or_file(target_path) else: raise AppError("Target already exists: %r" % target_path) with atomic_output_file(target_path) as temp_dir: make_all_dirs(temp_dir) ARCHIVER.unarchive(archive_path, temp_dir)
def _decompress_dir(archive_path, target_path, force=False): if os.path.exists(target_path): if force: log.info("deleting previous dir: %s", target_path) _rmtree_fast(target_path) else: raise AppError("Target already exists: %r" % target_path) with atomic_output_file(target_path) as temp_dir: make_all_dirs(temp_dir) ARCHIVER.unarchive(archive_path, temp_dir)
def setup(self): """Lazy initialize file cache post instantiation.""" if not self.setup_done: if os.path.exists(self.version_path): log.info("using cache: %s", self.root_path) else: log.info("initializing new cache: %s", self.root_path) make_all_dirs(self.contents_path) write_string_to_file(self.version_path, FileCache.version + "\n") self.setup_done = True