From 71f0fecda76cb0ca2d6505d3501438cd9c33339c Mon Sep 17 00:00:00 2001 From: ab1nash Date: Sat, 28 Sep 2019 23:49:13 +0000 Subject: [PATCH] scripts: Clean up output from 'clean_unused_caches'. The output log from running clean_unused_caches was too verbose as part of the `upgrade-zulip` overall output. While this output is potentially helpful when running it directly for debugging, it's certainly redundant for the main production use case. So a new flag --no-print-headers is introduced. It suppresses the header outputs for the subtools. Fixes #13214. --- scripts/lib/zulip_tools.py | 12 ++++++++---- scripts/purge-old-deployments | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 6bff283123..103da55aac 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -74,6 +74,10 @@ def parse_cache_script_args(description): "--verbose", dest="verbose", action="store_true", help="If specified then script will print a detailed report " "of what is being will deleted/kept back.") + parser.add_argument( + "--no-print-headings", dest="no_headings", action="store_true", + help="If specified then script will not print headings for " + "what will be deleted/kept back.") args = parser.parse_args() args.verbose |= args.dry_run # Always print a detailed report in case of dry run. @@ -290,7 +294,7 @@ def purge_unused_caches(caches_dir, caches_in_use, cache_type, args): caches_to_keep = all_caches - caches_to_purge may_be_perform_purging( - caches_to_purge, caches_to_keep, cache_type, args.dry_run, args.verbose) + caches_to_purge, caches_to_keep, cache_type, args.dry_run, args.verbose, args.no_headings) if args.verbose: print("Done!") @@ -321,11 +325,11 @@ def generate_sha1sum_emoji(zulip_path): return sha.hexdigest() -def may_be_perform_purging(dirs_to_purge, dirs_to_keep, dir_type, dry_run, verbose): - # type: (Set[str], Set[str], str, bool, bool) -> None +def may_be_perform_purging(dirs_to_purge, dirs_to_keep, dir_type, dry_run, verbose, no_headings): + # type: (Set[str], Set[str], str, bool, bool, bool) -> None if dry_run: print("Performing a dry run...") - else: + if not no_headings: print("Cleaning unused %ss..." % (dir_type,)) for directory in dirs_to_purge: diff --git a/scripts/purge-old-deployments b/scripts/purge-old-deployments index 2c65cd3ad1..155d87d235 100755 --- a/scripts/purge-old-deployments +++ b/scripts/purge-old-deployments @@ -59,7 +59,7 @@ def main(): 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, args.verbose) + deployments_to_purge, deployments_to_keep, "deployment", args.dry_run, args.verbose, True) if not args.dry_run: print("Deployments cleaned successfully...")