Esempio n. 1
0
    caches_in_use = set()

    if ENV == "prod":
        setups_to_check |= get_recent_deployments(threshold_days)
    if ENV == "dev":
        CACHE_SYMLINK = os.path.join(ZULIP_PATH, "static", "generated",
                                     "emoji")
        CURRENT_CACHE = os.path.dirname(os.path.realpath(CACHE_SYMLINK))
        caches_in_use.add(CURRENT_CACHE)

    for setup_dir in setups_to_check:
        emoji_link_path = os.path.join(setup_dir, "static/generated/emoji")
        if not os.path.islink(emoji_link_path):
            # This happens for a deployment directory extracted from a
            # tarball, which just has a copy of the emoji data, not a symlink.
            continue
        # The actual cache path doesn't include the /emoji
        caches_in_use.add(os.path.dirname(os.readlink(emoji_link_path)))
    return caches_in_use


def main(args: argparse.Namespace) -> None:
    caches_in_use = get_caches_in_use(args.threshold_days)
    purge_unused_caches(EMOJI_CACHE_PATH, caches_in_use, "emoji cache", args)


if __name__ == "__main__":
    args = parse_cache_script_args(
        "This script cleans unused zulip emoji caches.")
    main(args)
Esempio n. 2
0
    if ENV == "prod":
        setups_to_check |= get_recent_deployments(threshold_days)
    if ENV == "dev":
        add_current_venv_cache("zulip-py3-venv")
        add_current_venv_cache("zulip-thumbor-venv")

    for path in setups_to_check:
        reqs_dir = os.path.join(path, "requirements")
        # If the target directory doesn't contain a requirements
        # directory, skip it to avoid throwing an exception trying to
        # list its requirements subdirectory.
        if not os.path.exists(reqs_dir):
            continue
        for filename in os.listdir(reqs_dir):
            requirements_file = os.path.join(reqs_dir, filename)
            deps = expand_reqs(requirements_file)
            hash_val = hash_deps(deps)
            caches_in_use.add(os.path.join(VENV_CACHE_DIR, hash_val))

    return caches_in_use

def main(args: argparse.Namespace) -> None:
    caches_in_use = get_caches_in_use(args.threshold_days)
    purge_unused_caches(
        VENV_CACHE_DIR, caches_in_use, "venv cache", args)

if __name__ == "__main__":
    args = parse_cache_script_args("This script cleans unused zulip venv caches.")
    main(args)
Esempio n. 3
0
    """
    current_version_dir = os.path.join(YARN_CACHE_PATH, CURRENT_VERSION)
    try:
        dirs_to_purge = {
            os.path.join(YARN_CACHE_PATH, directory)
            for directory in os.listdir(YARN_CACHE_PATH)
            if directory != CURRENT_VERSION
        }
    except FileNotFoundError:
        return

    no_headings = getattr(args, "no_headings", False)
    may_be_perform_purging(
        dirs_to_purge,
        {current_version_dir},
        "yarn cache",
        args.dry_run,
        args.verbose,
        no_headings,
    )


def main(args: argparse.Namespace) -> None:
    remove_unused_versions_dir(args)


if __name__ == "__main__":
    args = parse_cache_script_args(
        "This script cleans redundant Zulip yarn caches.")
    main(args)
#!/usr/bin/env python3
import argparse
import os
import sys

ZULIP_PATH = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(ZULIP_PATH)
from scripts.lib import clean_emoji_cache, clean_node_cache, clean_venv_cache, clean_yarn_cache
from scripts.lib.zulip_tools import parse_cache_script_args


def main(args: argparse.Namespace) -> None:
    os.chdir(ZULIP_PATH)
    clean_venv_cache.main(args)
    clean_node_cache.main(args)
    clean_yarn_cache.main(args)
    clean_emoji_cache.main(args)


if __name__ == "__main__":
    args = parse_cache_script_args("This script cleans unused Zulip caches.")
    main(args)