<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 23, 2015 at 3:05 AM, Paul Eggleton <span dir="ltr">&lt;<a href="mailto:paul.eggleton@linux.intel.com" target="_blank">paul.eggleton@linux.intel.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":1h4" class="a3s" style="overflow:hidden">-def setup_tinfoil(config_only=False):<br>
+def setup_tinfoil(config_only=False, basepath=None):<br>
     &quot;&quot;&quot;Initialize tinfoil api from <span class="il">bitbake</span>&quot;&quot;&quot;<br>
     import scriptpath<br>
+    orig_cwd = os.path.abspath(os.curdir)<br>
+    if basepath:<br>
+        os.chdir(basepath)<br>
     bitbakepath = scriptpath.add_bitbake_lib_path()<br>
     if not bitbakepath:<br>
         logger.error(&quot;Unable to find <span class="il">bitbake</span> by searching parent directory of this script or PATH&quot;)<br>
@@ -108,6 +111,7 @@ def setup_tinfoil(config_only=False):<br>
     tinfoil = <span class="il">bb</span>.tinfoil.Tinfoil()<br>
     tinfoil.prepare(config_only)<br>
     tinfoil.logger.setLevel(logger.getEffectiveLevel())<br>
+    os.chdir(orig_cwd)<br>
     return tinfoil</div></blockquote></div><br>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.<br>-- <br><div class="gmail_signature">Christopher Larson<br>clarson at kergoth dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Maintainer - Tslib<br>Senior Software Engineer, Mentor Graphics</div>
</div></div>