From: Zack Cerza Date: Fri, 29 Apr 2016 19:16:56 +0000 (-0600) Subject: Move subdir removal logic into separate function X-Git-Tag: 1.1.0~619^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3d2ee71e140154e97ce37345af287150cfce5e05;p=teuthology.git Move subdir removal logic into separate function Signed-off-by: Zack Cerza --- diff --git a/teuthology/prune.py b/teuthology/prune.py index 2b5114ce87..95937e1f68 100644 --- a/teuthology/prune.py +++ b/teuthology/prune.py @@ -148,11 +148,18 @@ def maybe_remove_remotes(run_dir, days, dry_run=False): if (should_preserve(item) or not os.path.isdir(item) or not is_old_enough(item, days)): continue - # Does it have a remote subdir? - remote_path = os.path.join(item, 'remote') - if not os.path.isdir(remote_path): - continue - log.info("{job} is {days} days old; removing remote logs".format( - job=item, days=days)) - if not dry_run: - remove(remote_path) + _maybe_remove_subdir(item, 'remote', days, 'remote logs', dry_run) + + +def _maybe_remove_subdir(job_dir, subdir, days, description, dry_run=False): + # Does the subdir exist? + subdir_path = os.path.join(job_dir, subdir) + if not os.path.isdir(subdir_path): + return + log.info("{job} is {days} days old; removing {desc}".format( + job=job_dir, + days=days, + desc=description, + )) + if not dry_run: + remove(subdir_path)