aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Draszik <git@andred.net>2017-02-16 14:58:29 +0000
committerPatrick Ohly <patrick.ohly@intel.com>2017-02-17 08:41:07 +0100
commitafaba11d8009de40fcf38bd241ff8740b3a3a386 (patch)
treeb3d5d58f72c562e8e6d5a91ca4bbf38241980cc0
parentc63e8c0d95604ee5e4220cb093a3c5ab7c60c0b5 (diff)
downloadmeta-swupd-afaba11d8009de40fcf38bd241ff8740b3a3a386.tar.gz
meta-swupd-afaba11d8009de40fcf38bd241ff8740b3a3a386.tar.bz2
meta-swupd-afaba11d8009de40fcf38bd241ff8740b3a3a386.zip
path.py: always clean up temporary file in copyxattrfiles()
Use try: finally: to make sure the file is removed even on exceptions. Signed-off-by: André Draszik <git@andred.net>
-rw-r--r--lib/swupd/path.py10
1 files 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):