public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: [PATCH] Skip over event handler calls with incomplete environment
Date: Wed, 7 Feb 2018 16:59:47 +0100	[thread overview]
Message-ID: <b0dd3040-3f8a-740c-c2de-2b55fdd90cfc@siemens.com> (raw)

From: Jan Kiszka <jan.kiszka@siemens.com>

The cleanup handler is called a couple of times per shutdown and,
depending on the setup, some may not have a complete config. Avoid that
we stumble and fall over any of the environment variables being
undefined.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta/classes/isar-events.bbclass | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/meta/classes/isar-events.bbclass b/meta/classes/isar-events.bbclass
index ae0f791..4b5e97e 100644
--- a/meta/classes/isar-events.bbclass
+++ b/meta/classes/isar-events.bbclass
@@ -15,15 +15,16 @@ python isar_handler () {
         distro = d.getVar('DISTRO', True)
         arch = d.getVar('DISTRO_ARCH', True)
 
-        w = tmpdir + '/work/' + distro + '-' + arch
+        if tmpdir and distro and arch:
+            w = tmpdir + '/work/' + distro + '-' + arch
 
-        # '/proc/mounts' contains all the active mounts, so knowing 'w' we
-        # could get the list of mounts for the specific multiconfig and
-        # clean them.
-        with open('/proc/mounts', 'rU') as f:
-            for line in f:
-                if w in line:
-                    subprocess.call('sudo umount -f ' + line.split()[1], stdout=devnull, stderr=devnull, shell=True)
+            # '/proc/mounts' contains all the active mounts, so knowing 'w' we
+            # could get the list of mounts for the specific multiconfig and
+            # clean them.
+            with open('/proc/mounts', 'rU') as f:
+                for line in f:
+                    if w in line:
+                        subprocess.call('sudo umount -f ' + line.split()[1], stdout=devnull, stderr=devnull, shell=True)
 
     devnull.close()
 }
-- 
2.13.6

             reply	other threads:[~2018-02-07 15:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 15:59 Jan Kiszka [this message]
2018-02-07 16:12 ` Alexander Smirnov
2018-02-08  7:27   ` Jan Kiszka

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=b0dd3040-3f8a-740c-c2de-2b55fdd90cfc@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=isar-users@googlegroups.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox