]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move subdir removal logic into separate function
authorZack Cerza <zack@redhat.com>
Fri, 29 Apr 2016 19:16:56 +0000 (13:16 -0600)
committerZack Cerza <zack@redhat.com>
Fri, 29 Apr 2016 19:27:02 +0000 (13:27 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/prune.py

index 2b5114ce87e584e4e4de5b06580fd6a41025d88f..95937e1f6830d1b3c87b877f2d9a4e688dc1c4e4 100644 (file)
@@ -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)