Hi all,
I have a potential approach that I’d love to get some feedback on. The idea is
to inject the class into the global namespace, using an immediate variable
expansion to trigger the installation. This is nice because it means you can
write the progress handler directly in the .bb file, alongside the task itself.
def install_progress_handler():
from bb.progress import ProgressHandler
class BarProgressHandler(ProgressHandler):
def __init__(self, d, outfile=None):
super(BarProgressHandler, self).__init__(d, outfile)
self._fire_progress(0)
def write(self, string):
# >> bar stuff here <<
super(BarProgressHandler, self).write(string)
__builtins__["BarProgressHandler"] = BarProgressHandler
INITIALIZER := "${@install_progress_handler()}"
Then a varflag (either [progress] or a perhaps new one) will be used to pass
the name of the class to instantiate.
Looks like BB_SIGNATURE_HANDLER and BB_SCHEDULERS do something similar.
Thoughts?
Chris
From: openembedded-core-boun...@lists.openembedded.org
[mailto:openembedded-core-boun...@lists.openembedded.org] On Behalf Of Chris
Laplante via Openembedded-core
Sent: Saturday, April 14, 2018 8:52 PM
To: otavio.salva...@ossystems.com.br
Cc:
Subject: Re: [OE-core] Custom progress handlers
Great, I'll give it a go then :)
The type of progress output I'm handling is that of a fixed-width bar that
fills up with a certain character (e.g. '*' or '#"). Just like BitBake's own
output.
Moreover I want to generalize it to support multiple weighted stages, e.g.:
STAGE 1: message
[##]
STAGE 2: message 2
[ ]
To the progress handler, a stage generally looks like:
[ ]
[# ]
[##]
[### ]
… etc.
Will also try to handle the case of an embedded spinner, e.g.: | / - \ -
Thanks again for the encouragement :)
Chris
-Original Message-
From: Otavio Salvador [mailto:otavio.salva...@ossystems.com.br]
Sent: Saturday, April 14, 2018 5:05 PM
To: LAPLANTE,CHRIS (A-Little Falls,ex1)
<chris.lapla...@agilent.com<mailto:chris.lapla...@agilent.com>>
Cc: Patches and discussions about the oe-core layer
<openembedded-core@lists.openembedded.org<mailto:openembedded-core@lists.openembedded.org>>
Subject: Re: [OE-core] Custom progress handlers
On Sat, Apr 14, 2018 at 11:56 AM, Chris Laplante via Openembedded-core
<openembedded-core@lists.openembedded.org<mailto:openembedded-core@lists.openembedded.org>>
wrote:
> I have implemented a simple custom progress handler in
> bitbake/lib/bb/progress.py. It’s designed to handle bar-style
> progress. To use it for my shell tasks, I have modified
> “exec_func_shell” in bitbake/lib/bb/build.py. It’s implemented as a new value
> for the “progress”
> varflag.
>
> Is there a better, more extensible way to add a custom progress
> handler that doesn’t require modifying progress.py and build.py? It
> would be nice to be able to specify the name of the progress handler
> class to use (e.g. via a [progress-class] varflag) and then have build.py
> dynamically instantiate it.
> Is that possible? If so, would OE be interested in a patch to implement it?
I see no problem in adding it; I am curious about your custom handler as well
:-)
--
Otavio Salvador O.S. Systems
http://www.ossystems.com.brhttp://code.ossystems.com.br
Mobile: +55 (53) 9981-7854Mobile: +1 (347) 903-9750
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core