From: Zack Cerza Date: Thu, 3 Jul 2014 00:26:52 +0000 (-0600) Subject: Optionally, don't remove a repo when errors occur X-Git-Tag: v0.94.10~27^2^2~364^2~63 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97bf86c535cc40c1583d3cd34adb6920b0cfabd6;p=ceph.git Optionally, don't remove a repo when errors occur Signed-off-by: Zack Cerza --- diff --git a/teuthology/repo_utils.py b/teuthology/repo_utils.py index bf5a28cbbb97..6538f0d371cd 100644 --- a/teuthology/repo_utils.py +++ b/teuthology/repo_utils.py @@ -7,7 +7,7 @@ import time log = logging.getLogger(__name__) -def enforce_repo_state(repo_url, dest_path, branch): +def enforce_repo_state(repo_url, dest_path, branch, remove_on_error=True): """ Use git to either clone or update a given repo, forcing it to switch to the specified branch. @@ -15,6 +15,7 @@ def enforce_repo_state(repo_url, dest_path, branch): :param repo_url: The full URL to the repo (not including the branch) :param dest_path: The full path to the destination directory :param branch: The branch. + :param remove: Whether or not to remove dest_dir when an error occurs :raises: BranchNotFoundError if the branch is not found; RuntimeError for other errors """ @@ -33,7 +34,8 @@ def enforce_repo_state(repo_url, dest_path, branch): reset_repo(repo_url, dest_path, branch) except BranchNotFoundError: - shutil.rmtree(dest_path, ignore_errors=True) + if remove_on_error: + shutil.rmtree(dest_path, ignore_errors=True) raise