Use try: finally: to make sure the file is removed even
on exceptions.
Signed-off-by: André Draszik <[email protected]>
---
lib/swupd/path.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/swupd/path.py b/lib/swupd/path.py
index 61e979e..a55c22c 100644
--- a/lib/swupd/path.py
+++ b/lib/swupd/path.py
@@ -50,10 +50,12 @@ def copyxattrfiles(d, filelist, src, dst, archive=False):
bb.fatal('Extracting files from an archive and writing into an
archive not implemented yet.')
else:
cmd = "bsdtar --no-recursion -C %s -xf %s -T %s" % (dst, src,
copyfile)
- output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
- if output:
- bb.fatal('Unexpected output from the following command:\n%s\n%s' %
(cmd, output))
- os.remove(copyfile)
+ try:
+ output = subprocess.check_output(cmd, shell=True,
stderr=subprocess.STDOUT)
+ if output:
+ bb.fatal('Unexpected output from the following command:\n%s\n%s' %
(cmd, output))
+ finally:
+ os.remove(copyfile)
def remove_empty_directories(tree):
--
2.11.0
--
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto