[OE-core] [PATCH v2 1/3] devtool: second fix for running from a different directory

Paul Eggleton paul.eggleton at linux.intel.com
Wed Sep 23 16:04:34 UTC 2015


On Wednesday 23 September 2015 08:09:37 Christopher Larson wrote:
> 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.

That is a good point yes. I can send out a v3.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



More information about the Openembedded-core mailing list