diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-10-14 21:15:33 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-12-01 21:30:54 +0000 |
commit | a30b407474d4eb6620f1ec549b54187ebbaff008 (patch) | |
tree | 117a4dbef8df9ae8d112bf0e093e3795b2a65a19 | |
parent | 596dee8882ebddb45a6cce9f12aa919107106156 (diff) | |
download | openembedded-core-a30b407474d4eb6620f1ec549b54187ebbaff008.tar.gz openembedded-core-a30b407474d4eb6620f1ec549b54187ebbaff008.tar.bz2 openembedded-core-a30b407474d4eb6620f1ec549b54187ebbaff008.zip |
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.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r-- | scripts/lib/devtool/__init__.py | 26 |
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): |