aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/__init__.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-10-14 21:15:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-01 21:32:04 +0000
commit671f41e1d15307964dccc298270f2a739c297f41 (patch)
tree8204be054cc89dabd1a3f09081ba8968ca1534e4 /scripts/lib/devtool/__init__.py
parent74505b42956e6dec31436f56db13c1dfc2d8892a (diff)
downloadopenembedded-core-contrib-671f41e1d15307964dccc298270f2a739c297f41.tar.gz
devtool: ensure we change back to the original dir on error
This is just belt-and-braces but we ought to use try..finally in this kind of situation, so just do it. (From OE-Core rev: a30b407474d4eb6620f1ec549b54187ebbaff008) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/__init__.py')
-rw-r--r--scripts/lib/devtool/__init__.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index 50604e6e0d..e617d60405 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -100,18 +100,20 @@ def setup_tinfoil(config_only=False, basepath=None, tracking=False):
"""Initialize tinfoil api from bitbake"""
import scriptpath
orig_cwd = os.path.abspath(os.curdir)
- if basepath:
- os.chdir(basepath)
- bitbakepath = scriptpath.add_bitbake_lib_path()
- if not bitbakepath:
- logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
- sys.exit(1)
-
- import bb.tinfoil
- tinfoil = bb.tinfoil.Tinfoil(tracking=tracking)
- tinfoil.prepare(config_only)
- tinfoil.logger.setLevel(logger.getEffectiveLevel())
- os.chdir(orig_cwd)
+ try:
+ if basepath:
+ os.chdir(basepath)
+ bitbakepath = scriptpath.add_bitbake_lib_path()
+ if not bitbakepath:
+ logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
+ sys.exit(1)
+
+ import bb.tinfoil
+ tinfoil = bb.tinfoil.Tinfoil(tracking=tracking)
+ tinfoil.prepare(config_only)
+ tinfoil.logger.setLevel(logger.getEffectiveLevel())
+ finally:
+ os.chdir(orig_cwd)
return tinfoil
def get_recipe_file(cooker, pn):