<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>Thanks Chris. I will work on prototyping this. Since the documentation currently describes OE_IMPORTS as being “internal only”, I will modify it in base.bbclass from this:</div>
<div>&nbsp;</div>
<div style="text-indent:36pt;">OE_IMPORTS &#43;= &quot;os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license&quot;</div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div>To something like this:</div>
<div>&nbsp;</div>
<div style="text-indent:36pt;">OE_IMPORTS &#43;= &quot;os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license ${BB_PROGRESS_IMPORTS}&quot;</div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div>Is BB_PROGRESS_IMPORTS a suitable variable name?</div>
<div>&nbsp;</div>
<div>P.S. Sorry for terrible email formatting. I’m stuck with Outlook &#43; Exchange server at work. Will try to figure out something better.</div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div>Chris</div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div><font face="Yu Gothic"><b>From:</b> Christopher Larson &lt;kergoth@gmail.com&gt; <br>

<b>Sent:</b> Thursday, February 21, 2019 4:46 PM<br>

<b>To:</b> Richard Purdie &lt;richard.purdie@linuxfoundation.org&gt;<br>

<b>Cc:</b> LAPLANTE,CHRIS (A-Little Falls,ex1) &lt;chris.laplante@agilent.com&gt;; bitbake-devel@lists.openembedded.org<br>

<b>Subject:</b> Re: [bitbake-devel] [PATCH] build.py: support custom task [progress] handlers</font></div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div><font face="Calibri">This is a great idea, thanks a lot for contribution. As Richard says, I think using and hardcoding __builtins__ as the injection point isn’t ideal. Ideally I think we'd be able to provide a python module in a layer with the progress
handler, let OE_IMPORTS import it, and then let bitbake use it as is.</font></div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div><font face="Calibri">I think we just need to tweak it to accept the full name with imports, i.e. custom:oe.myprogressmodule.MyProgressHandler. Then if you want to inject it you can (though I think bb.context is better than __builtins__), or use an imported
module, whichever is preferred, rather than hardcoding the context.</font></div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div><font face="Calibri">Something like `<font face="Helvetica Neue" size="2" color="#262626"><span style="font-size:9pt;">functools.reduce(lambda x, y: x[y], cls.split(&quot;.&quot;), globals())` might do for resolving the dot-separated name to the class object, assuming
it’s already been imported.</span></font></font></div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div><font face="Calibri">On Thu, Feb 21, 2019 at 2:13 PM Richard Purdie &lt;<a href="mailto:richard.purdie@linuxfoundation.org"><font color="blue"><u>richard.purdie@linuxfoundation.org</u></font></a>&gt; wrote:</font></div>
<div><font face="Calibri">On Wed, 2018-10-03 at 22:48 -0400, Chris Laplante via bitbake-devel<br>

wrote:<br>

&gt; To use this mechanism, you need to inject your progress handler (i.e.<br>

&gt; something derived from bb.progress.ProgressHandler) into<br>

&gt; __builtins__.<br>

&gt; Here's one way to do it (from recipe-space):<br>

&gt; <br>

&gt;&nbsp; &nbsp; &nbsp;def install_my_progress_handler():<br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from bb.progress import ProgressHandler<br>

&gt; <br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;class MyProgressHandler(ProgressHandler):<br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pass<br>

&gt; <br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if &quot;MyProgressHandler&quot; not in __builtins__:<br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__builtins__[&quot;MyProgressHandler&quot;] = MyProgressHandler<br>

&gt; <br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return &quot;OK&quot;<br>

&gt; <br>

&gt;&nbsp; &nbsp; &nbsp;_INSTALL_MY_PROGRESS_HANDLERS := &quot;${@install_my_progress_handler(<br>

&gt; )}&quot;<br>

<br>

Sorry about the lack of review.<br>

<br>

My concern on this is the fact we have to poke around __builtins__. I<br>

understand why, I just can't help wonder if there is a better way<br>

somehow.<br>

<br>

I'm not sure I have a better one, not sure if Chris or others might?<br>

<br>

Cheers,<br>

<br>

Richard<br>

<br>

<br>

&gt; To install on a task:<br>

&gt;&nbsp; &nbsp; &nbsp;do_task[progress] = &quot;custom:MyProgressHandler&quot;<br>

&gt; <br>

&gt; To install on a task and pass extra arguments:<br>

&gt;&nbsp; &nbsp; &nbsp;do_task[progress] = &quot;custom:MyProgressHandler:my-arg&quot;<br>

&gt; <br>

&gt; Signed-off-by: Chris Laplante &lt;<a href="mailto:chris.laplante@agilent.com"><font color="blue"><u>chris.laplante@agilent.com</u></font></a>&gt;<br>

&gt; ---<br>

&gt;&nbsp; lib/bb/build.py | 8 &#43;&#43;&#43;&#43;&#43;&#43;&#43;&#43;<br>

&gt;&nbsp; 1 file changed, 8 insertions(&#43;)<br>

&gt; <br>

&gt; diff --git a/lib/bb/build.py b/lib/bb/build.py<br>

&gt; index 3e2a94e..2e14572 100644<br>

&gt; --- a/lib/bb/build.py<br>

&gt; &#43;&#43;&#43; b/lib/bb/build.py<br>

&gt; @@ -387,6 &#43;387,14 @@ exit $ret<br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif progress.startswith('outof:'):<br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Use specified regex<br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; logfile = bb.progress.OutOfProgressHandler(d,<br>

&gt; regex=progress.split(':', 1)[1], outfile=logfile)<br>

&gt; &#43;&nbsp; &nbsp; &nbsp; &nbsp; elif progress.startswith(&quot;custom:&quot;):<br>

&gt; &#43;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Use a custom progress handler<br>

&gt; &#43;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; parts = progress.split(&quot;:&quot;, 2)<br>

&gt; &#43;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _, cls, otherargs = parts[0], parts[1], (parts[2] or<br>

&gt; None) if parts[2:] else None<br>

&gt; &#43;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if cls and cls in __builtins__:<br>

&gt; &#43;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; logfile = __builtins__[cls](d, outfile=logfile,<br>

&gt; otherargs=otherargs)<br>

&gt; &#43;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br>

&gt; &#43;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bb.warn('%s: unknown custom progress handler in task<br>

&gt; progress varflag value &quot;%s&quot;, ignoring' % (func, cls))<br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else:<br>

&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bb.warn('%s: invalid task progress varflag value &quot;%s&quot;,<br>

&gt; ignoring' % (func, progress))<br>

&gt;&nbsp; <br>

&gt; -- <br>

&gt; 2.7.4<br>

&gt; <br>

<br>

-- <br>

_______________________________________________<br>

bitbake-devel mailing list<br>

<a href="mailto:bitbake-devel@lists.openembedded.org"><font color="blue"><u>bitbake-devel@lists.openembedded.org</u></font></a><br>

<a href="http://lists.openembedded.org/mailman/listinfo/bitbake-devel"><font color="blue"><u>http://lists.openembedded.org/mailman/listinfo/bitbake-devel</u></font></a></font></div>
<div><font face="Times New Roman"><br>

</font></div>
<div><font face="Times New Roman">&nbsp;</font></div>
<div><font face="Calibri">-- </font></div>
<div><font face="Calibri">Christopher Larson<br>

kergoth at gmail dot com<br>

Founder - BitBake, OpenEmbedded, OpenZaurus<br>

Senior Software Engineer, Mentor Graphics</font></div>
<div><font face="Times New Roman">&nbsp;</font></div>
</span></font>
</body>
</html>