throw warning (instead of crashing) when temp dir can't be cleaned

This commit is contained in:
svlandeg 2020-06-29 18:16:39 +02:00
parent efe7eb71f2
commit 894b8e7ff6
3 changed files with 7 additions and 3 deletions

View File

@ -243,8 +243,8 @@ def project_clone(
raise RuntimeError(f"Could not clone the repo '{repo}' into the temp dir '{tmp_dir}'.")
with (tmp_dir / ".git" / "info" / "sparse-checkout").open("w") as f:
f.write(name)
run_command(["git", "-C", tmp_dir, "fetch"])
run_command(["git", "-C", tmp_dir, "checkout"])
run_command(["git", "-C", str(tmp_dir), "fetch"])
run_command(["git", "-C", str(tmp_dir), "checkout"])
shutil.move(str(tmp_dir / Path(name).name), str(project_dir))
msg.good(f"Cloned project '{name}' from {repo}")
for sub_dir in DIRS:

View File

@ -132,6 +132,7 @@ class Warnings(object):
"are currently: da, de, el, en, id, lb, pt, ru, sr, ta, th.")
# TODO: fix numbering after merging develop into master
W091 = ("Could not clean/remove the temp directory at {dir}.")
W092 = ("Ignoring annotations for sentence starts, as dependency heads are set.")
W093 = ("Could not find any data to train the {name} on. Is your "
"input data correctly formatted ?")

View File

@ -467,7 +467,10 @@ def make_tempdir():
"""
d = Path(tempfile.mkdtemp())
yield d
try:
shutil.rmtree(str(d))
except PermissionError:
warnings.warn(Warnings.W091.format(dir=d))
def get_hash(data) -> str: