[OE-core] [PATCH v2 1/3] devtool: second fix for running from a different directory
Christopher Larson
clarson at kergoth.com
Wed Sep 23 15:09:37 UTC 2015
On Wed, Sep 23, 2015 at 3:05 AM, Paul Eggleton <
paul.eggleton at linux.intel.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20150923/bc22ab59/attachment-0002.html>
More information about the Openembedded-core
mailing list