示例#1
0
def _print_space():
    cli.out("disk_space:")
    _print_disk_usage("guild_home", config.guild_home())
    _print_disk_usage("runs", var.runs_dir())
    _print_disk_usage("deleted_runs", var.runs_dir(deleted=True))
    _print_disk_usage("remote_state", var.remote_dir())
    _print_disk_usage("cache", var.cache_dir())
示例#2
0
 def _file_type_info(self, path):
     typeDesc, icon, iconTooltip, viewer = self._base_file_type_info(path)
     if os.path.islink(path):
         target = os.path.realpath(path)
         link_type = "directory" if os.path.isdir(target) else "file"
         if target.startswith(var.runs_dir()):
             typeDesc = "Link to operation output"
         elif target.startswith(var.cache_dir()):
             typeDesc = "Link to resource {}".format(link_type)
         else:
             typeDesc = "Link"
         icon = "folder-move" if link_type == "directory" else "file-send"
         iconTooltip = "Link"
     return typeDesc, icon, iconTooltip, viewer
示例#3
0
def _unpack_dir(source_path, explicit_unpack_dir):
    """Returns unpack dir for local archives.

    If explicit_unpack_dir is specified (non blank) it is always
    used. Otherwise a location under the resource cache is used
    based on the value of source_path. In this case, source_path
    must be absolute.

    As with downloaded archives, local archives are unacked into a
    resource cache dir. This avoid unpacking project local files
    within the project.

    """
    if explicit_unpack_dir:
        return explicit_unpack_dir
    assert os.path.isabs(source_path), source_path
    digest = _file_source_digest(source_path)
    return os.path.join(var.cache_dir("resources"), digest)
示例#4
0
def _print_disk_usage():
    cli.out("disk_space:")
    paths = [
        ("guild_home", config.guild_home()),
        ("runs", var.runs_dir()),
        ("deleted_runs", var.runs_dir(deleted=True)),
        ("remote_state", var.remote_dir()),
        ("cache", var.cache_dir()),
    ]
    formatted_disk_usage = [
        _formatted_disk_usage(path) for _name, path in paths
    ]
    max_disk_usage_width = max([len(s) for s in formatted_disk_usage])
    for (name, path), disk_usage in zip(paths, formatted_disk_usage):
        _attr(
            "  %s" % name,
            _format_disk_usage_and_path(disk_usage, path,
                                        max_disk_usage_width),
        )
示例#5
0
 def __init__(self, path=None):
     self.path = path or var.cache_dir("runs")
     self._db = self._init_db()
     self._attr_reader = AttrReader()
     self._flag_reader = FlagReader()
     self._scalar_reader = ScalarReader(self._db)
示例#6
0
def url_source_download_dir(source):
    key = "\n".join(source.parsed_uri).encode("utf-8")
    digest = hashlib.sha224(key).hexdigest()
    return os.path.join(var.cache_dir("resources"), digest)
示例#7
0
 def _cached_data_path(mod_path):
     cache_dir = var.cache_dir("import-flags")
     abs_path = os.path.abspath(mod_path)
     path_hash = hashlib.md5(abs_path.encode()).hexdigest()
     return os.path.join(cache_dir, path_hash)
示例#8
0
def _guild_resource_cache():
    return util.realpath(var.cache_dir("resources"))
示例#9
0
 def _cached_data_path(mod_path, base_args):
     cache_dir = var.cache_dir("import-flags")
     to_hash = "/".join([os.path.abspath(mod_path)] + base_args)
     hashed = hashlib.md5(to_hash.encode()).hexdigest()
     return os.path.join(cache_dir, hashed)
示例#10
0
 def __init__(self):
     self.path = var.cache_dir("runs")
     self._ix = None