<div dir="ltr"><div dir="ltr">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&#39;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.<div><br></div><div>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.</div><div><br></div><div>Something like `<font color="#262626" face="Helvetica Neue"><span style="font-size:12px">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></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 21, 2019 at 2:13 PM Richard Purdie &lt;<a href="mailto:richard.purdie@linuxfoundation.org">richard.purdie@linuxfoundation.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">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&#39;s one way to do it (from recipe-space):<br>
&gt; <br>
&gt;     def install_my_progress_handler():<br>
&gt;         from bb.progress import ProgressHandler<br>
&gt; <br>
&gt;         class MyProgressHandler(ProgressHandler):<br>
&gt;             pass<br>
&gt; <br>
&gt;         if &quot;MyProgressHandler&quot; not in __builtins__:<br>
&gt;             __builtins__[&quot;MyProgressHandler&quot;] = MyProgressHandler<br>
&gt; <br>
&gt;         return &quot;OK&quot;<br>
&gt; <br>
&gt;     _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&#39;t help wonder if there is a better way<br>
somehow.<br>
<br>
I&#39;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;     do_task[progress] = &quot;custom:MyProgressHandler&quot;<br>
&gt; <br>
&gt; To install on a task and pass extra arguments:<br>
&gt;     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" target="_blank">chris.laplante@agilent.com</a>&gt;<br>
&gt; ---<br>
&gt;  lib/bb/build.py | 8 ++++++++<br>
&gt;  1 file changed, 8 insertions(+)<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; +++ b/lib/bb/build.py<br>
&gt; @@ -387,6 +387,14 @@ exit $ret<br>
&gt;          elif progress.startswith(&#39;outof:&#39;):<br>
&gt;              # Use specified regex<br>
&gt;              logfile = bb.progress.OutOfProgressHandler(d,<br>
&gt; regex=progress.split(&#39;:&#39;, 1)[1], outfile=logfile)<br>
&gt; +        elif progress.startswith(&quot;custom:&quot;):<br>
&gt; +            # Use a custom progress handler<br>
&gt; +            parts = progress.split(&quot;:&quot;, 2)<br>
&gt; +            _, cls, otherargs = parts[0], parts[1], (parts[2] or<br>
&gt; None) if parts[2:] else None<br>
&gt; +            if cls and cls in __builtins__:<br>
&gt; +                logfile = __builtins__[cls](d, outfile=logfile,<br>
&gt; otherargs=otherargs)<br>
&gt; +            else:<br>
&gt; +                bb.warn(&#39;%s: unknown custom progress handler in task<br>
&gt; progress varflag value &quot;%s&quot;, ignoring&#39; % (func, cls))<br>
&gt;          else:<br>
&gt;              bb.warn(&#39;%s: invalid task progress varflag value &quot;%s&quot;,<br>
&gt; ignoring&#39; % (func, progress))<br>
&gt;  <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" target="_blank">bitbake-devel@lists.openembedded.org</a><br>
<a href="http://lists.openembedded.org/mailman/listinfo/bitbake-devel" rel="noreferrer" target="_blank">http://lists.openembedded.org/mailman/listinfo/bitbake-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Christopher Larson<br>kergoth at gmail dot com<br>Founder - BitBake, OpenEmbedded, OpenZaurus<br>Senior Software Engineer, Mentor Graphics</div></div></div></div>