[entropy.client.package] _generate_content_safety_file: do not catch Exception

Move the os.remove() call to the finally block and detect failures via
a status boolean. This way, warnings won't be raised as exceptions.
This commit is contained in:
Fabio Erculiani
2012-08-07 21:59:51 +02:00
parent 3294f9963b
commit 58cb8adf96
+7 -7
View File
@@ -4173,6 +4173,7 @@ class Package:
raise
tmp_fd, tmp_path = None, None
generated = False
try:
tmp_fd, tmp_path = tempfile.mkstemp(
prefix="PackageContentSafety",
@@ -4181,20 +4182,19 @@ class Package:
for path, sha256, mtime in content_safety:
tmp_f.write(path, sha256, mtime)
generated = True
return tmp_path
except Exception as exc:
if tmp_path is not None:
try:
os.remove(tmp_path)
except (OSError, IOError):
pass
raise exc
finally:
if tmp_fd is not None:
try:
os.close(tmp_fd)
except OSError:
pass
if tmp_path is not None and not generated:
try:
os.remove(tmp_path)
except (OSError, IOError):
pass
@staticmethod
def _generate_content_file(content, package_id = None):