[yocto] [meta-swupd][PATCH 2/3] path.py: always clean up temporary file in copyxattrfiles()
André Draszik
git at andred.net
Thu Feb 16 06:58:29 PST 2017
Use try: finally: to make sure the file is removed even
on exceptions.
Signed-off-by: André Draszik <git at andred.net>
---
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
More information about the yocto
mailing list