diff mbox series

[kirkstone,2.0] bitbake-getvar: Add a quiet command line argument

Message ID 20230824083109.1821425-1-Markus.Niebel@ew.tq-group.com
State Accepted, archived
Commit d677daa0770c66010fc4ed0af5bbbb94752ba590
Headers show
Series [kirkstone,2.0] bitbake-getvar: Add a quiet command line argument | expand

Commit Message

Markus Niebel Aug. 24, 2023, 8:31 a.m. UTC
From: Paulo Neves <ptsneves@gmail.com>

bitbake-getvar does not have a way to silence bitbake
server's logger and that makes the tool hard to use for
text processing. This is especially true when one wants to
get a bitbake value to be piped to some other utility and
instead we get uncontrolled logging messages or warnings
together with bitbake's variable value.

Example without quiet:
bitbake-getvar --value MACHINE
NOTE: Starting bitbake server...
qemux86-64

With quiet:
bitbake-getvar --value MACHINE --quiet
qemux86-64

Signed-off-by: Paulo Neves <ptsneves@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
(cherry picked from commit af354e975d0b4c26d0e91e3c82946b093bc11b45)
Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
---
 bin/bitbake-getvar | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jose Quaresma Sept. 6, 2023, 4:41 p.m. UTC | #1
Gentle ping.

Jose

Markus Niebel <Markus.Niebel@ew.tq-group.com> escreveu no dia quinta,
24/08/2023 à(s) 09:59:

> From: Paulo Neves <ptsneves@gmail.com>
>
> bitbake-getvar does not have a way to silence bitbake
> server's logger and that makes the tool hard to use for
> text processing. This is especially true when one wants to
> get a bitbake value to be piped to some other utility and
> instead we get uncontrolled logging messages or warnings
> together with bitbake's variable value.
>
> Example without quiet:
> bitbake-getvar --value MACHINE
> NOTE: Starting bitbake server...
> qemux86-64
>
> With quiet:
> bitbake-getvar --value MACHINE --quiet
> qemux86-64
>
> Signed-off-by: Paulo Neves <ptsneves@gmail.com>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> (cherry picked from commit af354e975d0b4c26d0e91e3c82946b093bc11b45)
> Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
> ---
>  bin/bitbake-getvar | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/bin/bitbake-getvar b/bin/bitbake-getvar
> index 5435a8d7..4a9eb4f3 100755
> --- a/bin/bitbake-getvar
> +++ b/bin/bitbake-getvar
> @@ -25,6 +25,7 @@ if __name__ == "__main__":
>      parser.add_argument('-u', '--unexpand', help='Do not expand the value
> (with --value)', action="store_true")
>      parser.add_argument('-f', '--flag', help='Specify a variable flag to
> query (with --value)', default=None)
>      parser.add_argument('--value', help='Only report the value, no
> history and no variable name', action="store_true")
> +    parser.add_argument('-q', '--quiet', help='Silence bitbake server
> logging', action="store_true")
>      args = parser.parse_args()
>
>      if args.unexpand and not args.value:
> @@ -35,7 +36,7 @@ if __name__ == "__main__":
>          print("--flag only makes sense with --value")
>          sys.exit(1)
>
> -    with bb.tinfoil.Tinfoil(tracking=True) as tinfoil:
> +    with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not args.quiet)
> as tinfoil:
>          if args.recipe:
>              tinfoil.prepare(quiet=2)
>              d = tinfoil.parse_recipe(args.recipe)
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#14972):
> https://lists.openembedded.org/g/bitbake-devel/message/14972
> Mute This Topic: https://lists.openembedded.org/mt/100931867/5052612
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [
> quaresma.jose@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Etienne Cordonnier Oct. 3, 2023, 4:05 p.m. UTC | #2
Is there a technical issue preventing a merge of the patch, or is it
delayed due to the current workload?

Thanks,
Etienne

On Wed, Sep 6, 2023 at 6:41 PM Jose Quaresma <quaresma.jose@gmail.com>
wrote:

> Gentle ping.
>
> Jose
>
> Markus Niebel <Markus.Niebel@ew.tq-group.com> escreveu no dia quinta,
> 24/08/2023 à(s) 09:59:
>
>> From: Paulo Neves <ptsneves@gmail.com>
>>
>> bitbake-getvar does not have a way to silence bitbake
>> server's logger and that makes the tool hard to use for
>> text processing. This is especially true when one wants to
>> get a bitbake value to be piped to some other utility and
>> instead we get uncontrolled logging messages or warnings
>> together with bitbake's variable value.
>>
>> Example without quiet:
>> bitbake-getvar --value MACHINE
>> NOTE: Starting bitbake server...
>> qemux86-64
>>
>> With quiet:
>> bitbake-getvar --value MACHINE --quiet
>> qemux86-64
>>
>> Signed-off-by: Paulo Neves <ptsneves@gmail.com>
>> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
>> (cherry picked from commit af354e975d0b4c26d0e91e3c82946b093bc11b45)
>> Signed-off-by: Markus Niebel <Markus.Niebel@ew.tq-group.com>
>> ---
>>  bin/bitbake-getvar | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/bin/bitbake-getvar b/bin/bitbake-getvar
>> index 5435a8d7..4a9eb4f3 100755
>> --- a/bin/bitbake-getvar
>> +++ b/bin/bitbake-getvar
>> @@ -25,6 +25,7 @@ if __name__ == "__main__":
>>      parser.add_argument('-u', '--unexpand', help='Do not expand the
>> value (with --value)', action="store_true")
>>      parser.add_argument('-f', '--flag', help='Specify a variable flag to
>> query (with --value)', default=None)
>>      parser.add_argument('--value', help='Only report the value, no
>> history and no variable name', action="store_true")
>> +    parser.add_argument('-q', '--quiet', help='Silence bitbake server
>> logging', action="store_true")
>>      args = parser.parse_args()
>>
>>      if args.unexpand and not args.value:
>> @@ -35,7 +36,7 @@ if __name__ == "__main__":
>>          print("--flag only makes sense with --value")
>>          sys.exit(1)
>>
>> -    with bb.tinfoil.Tinfoil(tracking=True) as tinfoil:
>> +    with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not args.quiet)
>> as tinfoil:
>>          if args.recipe:
>>              tinfoil.prepare(quiet=2)
>>              d = tinfoil.parse_recipe(args.recipe)
>> --
>> 2.25.1
>>
>>
>>
>>
>>
>
> --
> Best regards,
>
> José Quaresma
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#15014):
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_bitbake-2Ddevel_message_15014&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=28o5PCk2_SvEBbgcSr9uFO2XInJr64bYAT2f-8b0pVLcGrT6qjQgpWJahSmuCsJm&s=1N6X7NJdqFSuMeDnGQl04v2BtAMrwt-IEDztO_J3m-Y&e=
> Mute This Topic:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_mt_100931867_7048771&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=28o5PCk2_SvEBbgcSr9uFO2XInJr64bYAT2f-8b0pVLcGrT6qjQgpWJahSmuCsJm&s=mEgzk6IU8WykrVV08Koz1q1uEH0YZkyqWJmZqD5qsfI&e=
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.openembedded.org_g_bitbake-2Ddevel_unsub&d=DwIFaQ&c=ncDTmphkJTvjIDPh0hpF_4vCHvabgGkICC2epckfdiw&r=AhkbNonVuMIGRfPx_Qj9TsRih1DULJTKUkSGa66m67E&m=28o5PCk2_SvEBbgcSr9uFO2XInJr64bYAT2f-8b0pVLcGrT6qjQgpWJahSmuCsJm&s=kdUmyOXc4k-qkWGqZYP-xnO6SqTCMOYbkKpmeB7hnIw&e=
> [ecordonnier@snap.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Richard Purdie Oct. 3, 2023, 4:35 p.m. UTC | #3
On Tue, 2023-10-03 at 18:05 +0200, Etienne Cordonnier via
lists.openembedded.org wrote:
> Is there a technical issue preventing a merge of the patch, or is it
> delayed due to the current workload?

There were recent changes in master in this behaviour and it may make
sense to fix things together with the recent changes?

You should also copy Steve on LTS patches (added now).

Cheers,

Richard
Martin Jansa Nov. 3, 2023, 8:31 p.m. UTC | #4
Does it work with 2.0? With --quiet I'm seeing:

Traceback (most recent call last):
  File "bitbake/bin/bitbake-getvar", line 41, in <module>
    tinfoil.prepare(quiet=2)
  File "bitbake/lib/bb/tinfoil.py", line 389, in prepare
    for handler in self.localhandlers:
                   ^^^^^^^^^^^^^^^^^^
AttributeError: 'Tinfoil' object has no attribute 'localhandlers'. Did you
mean: 'oldhandlers'?

So bitbake 2.0 probably needs the fix
https://git.openembedded.org/bitbake/commit/?id=71ee69a20f21f3d37f4f060a7d8e87d9f1dc6aa1
from master as well.

On Tue, Oct 3, 2023 at 6:35 PM Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Tue, 2023-10-03 at 18:05 +0200, Etienne Cordonnier via
> lists.openembedded.org wrote:
> > Is there a technical issue preventing a merge of the patch, or is it
> > delayed due to the current workload?
>
> There were recent changes in master in this behaviour and it may make
> sense to fix things together with the recent changes?
>
> You should also copy Steve on LTS patches (added now).
>
> Cheers,
>
> Richard
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#15176):
> https://lists.openembedded.org/g/bitbake-devel/message/15176
> Mute This Topic: https://lists.openembedded.org/mt/100931867/3617156
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/bitbake-devel/leave/8021546/3617156/1661570722/xyzzy
> [martin.jansa@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
diff mbox series

Patch

diff --git a/bin/bitbake-getvar b/bin/bitbake-getvar
index 5435a8d7..4a9eb4f3 100755
--- a/bin/bitbake-getvar
+++ b/bin/bitbake-getvar
@@ -25,6 +25,7 @@  if __name__ == "__main__":
     parser.add_argument('-u', '--unexpand', help='Do not expand the value (with --value)', action="store_true")
     parser.add_argument('-f', '--flag', help='Specify a variable flag to query (with --value)', default=None)
     parser.add_argument('--value', help='Only report the value, no history and no variable name', action="store_true")
+    parser.add_argument('-q', '--quiet', help='Silence bitbake server logging', action="store_true")
     args = parser.parse_args()
 
     if args.unexpand and not args.value:
@@ -35,7 +36,7 @@  if __name__ == "__main__":
         print("--flag only makes sense with --value")
         sys.exit(1)
 
-    with bb.tinfoil.Tinfoil(tracking=True) as tinfoil:
+    with bb.tinfoil.Tinfoil(tracking=True, setup_logging=not args.quiet) as tinfoil:
         if args.recipe:
             tinfoil.prepare(quiet=2)
             d = tinfoil.parse_recipe(args.recipe)