From b0c0648a4f764c0689df0c5e1540e62425aba17d Mon Sep 17 00:00:00 2001 From: Aditya Bansal Date: Tue, 20 Feb 2018 05:44:20 +0530 Subject: [PATCH] clean-venv-cache: Handle cleaning up zulip-thumbor-venv properly. --- scripts/lib/clean-venv-cache | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/lib/clean-venv-cache b/scripts/lib/clean-venv-cache index 84b1735006..028b4d7252 100755 --- a/scripts/lib/clean-venv-cache +++ b/scripts/lib/clean-venv-cache @@ -4,6 +4,8 @@ import os import sys if False: + # Typing module isn't always available when this is run on older + # Python 3.4 (Trusty). from typing import Set, Text ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -23,12 +25,16 @@ def get_caches_in_use(threshold_days): setups_to_check = set([ZULIP_PATH, ]) caches_in_use = set() + def add_current_venv_cache(venv_name: str) -> None: + CACHE_SYMLINK = os.path.join(os.path.dirname(ZULIP_PATH), venv_name) + CURRENT_CACHE = os.path.dirname(os.path.realpath(CACHE_SYMLINK)) + caches_in_use.add(CURRENT_CACHE) + if ENV == "prod": setups_to_check |= get_recent_deployments(threshold_days) if ENV == "dev": - CACHE_SYMLINK = os.path.join(os.path.dirname(ZULIP_PATH), "zulip-py3-venv") - CURRENT_CACHE = os.path.dirname(os.path.realpath(CACHE_SYMLINK)) - caches_in_use.add(CURRENT_CACHE) + 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")