All of lore.kernel.org
 help / color / mirror / Atom feed
From: "André Draszik" <git@andred.net>
To: yocto@yoctoproject.org
Subject: [meta-swupd][PATCH 2/3] path.py: always clean up temporary file in copyxattrfiles()
Date: Thu, 16 Feb 2017 14:58:29 +0000	[thread overview]
Message-ID: <20170216145830.21766-3-git@andred.net> (raw)
In-Reply-To: <20170216145830.21766-1-git@andred.net>

Use try: finally: to make sure the file is removed even
on exceptions.

Signed-off-by: André Draszik <git@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



  parent reply	other threads:[~2017-02-16 14:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-16 14:58 [meta-swupd][PATCH 0/3] fixes for when SWUPD_BUNDLES is undefined André Draszik
2017-02-16 14:58 ` [meta-swupd][PATCH 1/3] swupd-image.bbclass: don't fail parsing if " André Draszik
2017-02-16 14:58 ` André Draszik [this message]
2017-02-16 14:58 ` [meta-swupd][PATCH 3/3] bundles.py: fix copying of full image to full bundle when no SWUPD_BUNDLES André Draszik
2017-02-16 15:41   ` Patrick Ohly
2017-02-16 15:50     ` Patrick Ohly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170216145830.21766-3-git@andred.net \
    --to=git@andred.net \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.