mirror of https://github.com/zulip/zulip.git
scripts: Make default mode of cache-cleaning scripts much less verbose.
Print a detailed report only if `--verbose` flag is specified. Fixes: #6632.
This commit is contained in:
parent
480ae626fb
commit
df7ea375c1
|
@ -237,7 +237,8 @@ def purge_unused_caches(caches_dir, caches_in_use, args, cache_type):
|
|||
caches_to_purge = get_caches_to_be_purged(caches_dir, caches_in_use, args.threshold_days)
|
||||
caches_to_keep = all_caches - caches_to_purge
|
||||
|
||||
may_be_perform_purging(caches_to_purge, caches_to_keep, cache_type, args.dry_run)
|
||||
may_be_perform_purging(
|
||||
caches_to_purge, caches_to_keep, cache_type, args.dry_run, args.verbose)
|
||||
print("Done!\n")
|
||||
|
||||
def generate_sha1sum_emoji(zulip_path):
|
||||
|
@ -263,17 +264,19 @@ def generate_sha1sum_emoji(zulip_path):
|
|||
|
||||
return sha.hexdigest()
|
||||
|
||||
def may_be_perform_purging(dirs_to_purge, dirs_to_keep, dir_type, dry_run):
|
||||
# type: (Set[Text], Set[Text], Text, bool) -> None
|
||||
def may_be_perform_purging(dirs_to_purge, dirs_to_keep, dir_type, dry_run, verbose):
|
||||
# type: (Set[Text], Set[Text], Text, bool, bool) -> None
|
||||
if dry_run:
|
||||
print("Performing a dry run...")
|
||||
else:
|
||||
print("Cleaning unused %ss..." % (dir_type,))
|
||||
|
||||
for directory in dirs_to_purge:
|
||||
if verbose:
|
||||
print("Cleaning unused %s: %s" % (dir_type, directory))
|
||||
if not dry_run:
|
||||
subprocess.check_call(["sudo", "rm", "-rf", directory])
|
||||
|
||||
for directory in dirs_to_keep:
|
||||
if verbose:
|
||||
print("Keeping used %s: %s" % (dir_type, directory))
|
||||
|
|
|
@ -60,7 +60,8 @@ def main():
|
|||
deployments_to_keep = get_recent_deployments(args.threshold_days)
|
||||
deployments_to_purge = get_deployments_to_be_purged(deployments_to_keep)
|
||||
|
||||
may_be_perform_purging(deployments_to_purge, deployments_to_keep, "deployment", args.dry_run)
|
||||
may_be_perform_purging(
|
||||
deployments_to_purge, deployments_to_keep, "deployment", args.dry_run, args.verbose)
|
||||
|
||||
if not args.dry_run:
|
||||
print("Deployments cleaned successfully...")
|
||||
|
|
Loading…
Reference in New Issue