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>
This commit is contained in:
parent
74505b4295
commit
671f41e1d1
|
@ -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)
|
||||
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())
|
||||
os.chdir(orig_cwd)
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue