summaryrefslogtreecommitdiffstats
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
parent74505b42956e6dec31436f56db13c1dfc2d8892a (diff)
downloadpoky-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>
-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):
100 """Initialize tinfoil api from bitbake""" 100 """Initialize tinfoil api from bitbake"""
101 import scriptpath 101 import scriptpath
102 orig_cwd = os.path.abspath(os.curdir) 102 orig_cwd = os.path.abspath(os.curdir)
103 if basepath: 103 try:
104 os.chdir(basepath) 104 if basepath:
105 bitbakepath = scriptpath.add_bitbake_lib_path() 105 os.chdir(basepath)
106 if not bitbakepath: 106 bitbakepath = scriptpath.add_bitbake_lib_path()
107 logger.error("Unable to find bitbake by searching parent directory of this script or PATH") 107 if not bitbakepath:
108 sys.exit(1) 108 logger.error("Unable to find bitbake by searching parent directory of this script or PATH")
109 109 sys.exit(1)
110 import bb.tinfoil 110
111 tinfoil = bb.tinfoil.Tinfoil(tracking=tracking) 111 import bb.tinfoil
112 tinfoil.prepare(config_only) 112 tinfoil = bb.tinfoil.Tinfoil(tracking=tracking)
113 tinfoil.logger.setLevel(logger.getEffectiveLevel()) 113 tinfoil.prepare(config_only)
114 os.chdir(orig_cwd) 114 tinfoil.logger.setLevel(logger.getEffectiveLevel())
115 finally:
116 os.chdir(orig_cwd)
115 return tinfoil 117 return tinfoil
116 118
117def get_recipe_file(cooker, pn): 119def get_recipe_file(cooker, pn):