Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
 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