On Wed, Sep 23, 2015 at 3:05 AM, Paul Eggleton <
[email protected]> wrote:
> -def setup_tinfoil(config_only=False):
> +def setup_tinfoil(config_only=False, basepath=None):
> """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")
> @@ -108,6 +111,7 @@ def setup_tinfoil(config_only=False):
> tinfoil = bb.tinfoil.Tinfoil()
> tinfoil.prepare(config_only)
> tinfoil.logger.setLevel(logger.getEffectiveLevel())
> + os.chdir(orig_cwd)
> return tinfoil
>
Just from a correctness standpoint, this will not go back to orig_cwd if an
exception is raised. We should be using a try/finally block for things like
this.
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core