clean-venv-cache: Fix an exception with unusual deployment dirs.

This commit is contained in:
Harshit Bansal 2017-10-30 01:51:46 +05:30 committed by Tim Abbott
parent 9bf81b7fa9
commit 48662a79a5
1 changed files with 8 additions and 2 deletions

View File

@ -31,8 +31,14 @@ def get_caches_in_use(threshold_days):
caches_in_use.add(CURRENT_CACHE)
for path in setups_to_check:
for filename in os.listdir(os.path.join(path, "requirements")):
requirements_file = os.path.join(path, "requirements", filename)
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))