catch exceptions when removing temporary directory

Additionally, don't try to remove it when it wasn't created in the first
place.
This commit is contained in:
Nils Philippsen
2016-08-24 14:58:45 +02:00
parent d65f4fed55
commit 1cd21434fb

View File

@@ -71,6 +71,7 @@ def submit_build():
return "The submitted scmurl isn't allowed", 403
yaml = str()
td = None
try:
td = tempfile.mkdtemp()
scm = rida.scm.SCM(url, conf.scmurls)
@@ -88,7 +89,13 @@ def submit_build():
rc = 500
return str(e), rc
finally:
shutil.rmtree(td)
try:
if td is not None:
shutil.rmtree(td)
except Exception as e:
log.warning(
"Failed to remove temporary directory {!r}: {}".format(
td, str(e)))
mmd = modulemd.ModuleMetadata()
try: