All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] bitbake : Paginate 'bitbake -e' using less.
@ 2017-06-26 21:02 Rob Woolley
  2017-06-27 13:56 ` Paul Eggleton
  0 siblings, 1 reply; 6+ messages in thread
From: Rob Woolley @ 2017-06-26 21:02 UTC (permalink / raw)
  To: Diana Thayer; +Cc: bitbake-devel

[-- Attachment #1: Type: text/plain, Size: 2925 bytes --]

Feel free to grab pieces from here, if you find it useful:
https://patchwork.openembedded.org/patch/89543/

I based it on the same logic used by git to determine whether the user had
a pager set already and whether or not the output was going to the terminal
or being piped to another process.

The feedback I got was that the functionality wasn't needed and users could
just pipe it to less if they wanted a pager:
http://lists.openembedded.org/pipermail/bitbake-devel/2015-March/005545.html

Regards,
Rob

On Mon, Jun 26, 2017 at 4:48 PM, Diana Thayer <garbados@gmail.com> wrote:

> Thank you for the feedback!
>
> I've added lines to check $OE_PAGER and $PAGER, such that `PAGER=cat
> bitbake -e` effectively disables pagination.
>
> Regarding the option '--paginate', would it capture output from whatever
> command has run? I'm not sure how to capture stdout at such a scope.
>
>
> On Tue, Jun 20, 2017 at 6:39 AM, Peter Kjellerstedt <
> peter.kjellerstedt@axis.com> wrote:
>
>> Basically, this change needs to be aware of the destination for the
>> output. If it is a tty, then it is fine to output to a viewer such as less,
>> but otherwise it should go to stdout as before. This should of course not
>> be hardcoded, but use environment variables, e.g., $OE_PAGER || $PAGER ||
>> less (inspired by git_pager() in the git source). You should also not
>> expect that everyone wants the options you have used for less. Looking
>> again at how git handles this, they use “LESS=FRX <command>” if the $LESS
>> environment variable is not set, and does not modify it if it is set. You
>> also want to add options such as --paginate and --no-pager (yet again
>> inspired by git) to bitbake.
>>
>>
>>
>> All in all, look at and be inspired by how git handles pagers, they have
>> this pretty well covered.
>>
>>
>>
>> //Peter
>>
>>
>>
>> *From:* bitbake-devel-bounces@lists.openembedded.org [mailto:
>> bitbake-devel-bounces@lists.openembedded.org] *On Behalf Of *Burton, Ross
>> *Sent:* den 20 juni 2017 12:06
>> *To:* Diana Thayer <garbados@gmail.com>
>> *Cc:* bitbake-devel <bitbake-devel@lists.openembedded.org>
>> *Subject:* Re: [bitbake-devel] [PATCH] bitbake : Paginate 'bitbake -e'
>> using less.
>>
>>
>>
>>
>>
>> On 20 June 2017 at 05:54, Diana Thayer <garbados@gmail.com> wrote:
>>
>> +        pager = subprocess.Popen(['less', '-F', '-R', '-S', '-X', '-K'],
>> +                                 stdin=subprocess.PIPE,
>> +                                 stdout=sys.stdout,
>> +                                 universal_newlines=True)
>>
>>
>> What if I'm piping bitbake -e though grep or into a file already?
>>
>>
>>
>> Ross
>>
>
>
> --
> _______________________________________________
> bitbake-devel mailing list
> bitbake-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/bitbake-devel
>
>

[-- Attachment #2: Type: text/html, Size: 6725 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bitbake : Paginate 'bitbake -e' using less.
  2017-06-26 21:02 [PATCH] bitbake : Paginate 'bitbake -e' using less Rob Woolley
@ 2017-06-27 13:56 ` Paul Eggleton
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Eggleton @ 2017-06-27 13:56 UTC (permalink / raw)
  To: bitbake-devel

On Monday, 26 June 2017 10:02:20 PM BST Rob Woolley wrote:
> Feel free to grab pieces from here, if you find it useful:
> https://patchwork.openembedded.org/patch/89543/
> 
> I based it on the same logic used by git to determine whether the user had
> a pager set already and whether or not the output was going to the terminal
> or being piped to another process.
> 
> The feedback I got was that the functionality wasn't needed and users could
> just pipe it to less if they wanted a pager:
> http://lists.openembedded.org/pipermail/bitbake-devel/2015-March/005545.html

FWIW I like this feature of git and would very much like to see it implemented 
for bitbake -e.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bitbake : Paginate 'bitbake -e' using less.
  2017-06-20 13:39   ` Peter Kjellerstedt
@ 2017-06-26 20:48     ` Diana Thayer
  0 siblings, 0 replies; 6+ messages in thread
From: Diana Thayer @ 2017-06-26 20:48 UTC (permalink / raw)
  To: Peter Kjellerstedt; +Cc: bitbake-devel

[-- Attachment #1: Type: text/plain, Size: 2056 bytes --]

Thank you for the feedback!

I've added lines to check $OE_PAGER and $PAGER, such that `PAGER=cat
bitbake -e` effectively disables pagination.

Regarding the option '--paginate', would it capture output from whatever
command has run? I'm not sure how to capture stdout at such a scope.


On Tue, Jun 20, 2017 at 6:39 AM, Peter Kjellerstedt <
peter.kjellerstedt@axis.com> wrote:

> Basically, this change needs to be aware of the destination for the
> output. If it is a tty, then it is fine to output to a viewer such as less,
> but otherwise it should go to stdout as before. This should of course not
> be hardcoded, but use environment variables, e.g., $OE_PAGER || $PAGER ||
> less (inspired by git_pager() in the git source). You should also not
> expect that everyone wants the options you have used for less. Looking
> again at how git handles this, they use “LESS=FRX <command>” if the $LESS
> environment variable is not set, and does not modify it if it is set. You
> also want to add options such as --paginate and --no-pager (yet again
> inspired by git) to bitbake.
>
>
>
> All in all, look at and be inspired by how git handles pagers, they have
> this pretty well covered.
>
>
>
> //Peter
>
>
>
> *From:* bitbake-devel-bounces@lists.openembedded.org [mailto:
> bitbake-devel-bounces@lists.openembedded.org] *On Behalf Of *Burton, Ross
> *Sent:* den 20 juni 2017 12:06
> *To:* Diana Thayer <garbados@gmail.com>
> *Cc:* bitbake-devel <bitbake-devel@lists.openembedded.org>
> *Subject:* Re: [bitbake-devel] [PATCH] bitbake : Paginate 'bitbake -e'
> using less.
>
>
>
>
>
> On 20 June 2017 at 05:54, Diana Thayer <garbados@gmail.com> wrote:
>
> +        pager = subprocess.Popen(['less', '-F', '-R', '-S', '-X', '-K'],
> +                                 stdin=subprocess.PIPE,
> +                                 stdout=sys.stdout,
> +                                 universal_newlines=True)
>
>
> What if I'm piping bitbake -e though grep or into a file already?
>
>
>
> Ross
>

[-- Attachment #2: Type: text/html, Size: 4892 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bitbake : Paginate 'bitbake -e' using less.
  2017-06-20 10:05 ` Burton, Ross
@ 2017-06-20 13:39   ` Peter Kjellerstedt
  2017-06-26 20:48     ` Diana Thayer
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Kjellerstedt @ 2017-06-20 13:39 UTC (permalink / raw)
  To: Burton, Ross, Diana Thayer; +Cc: bitbake-devel

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

Basically, this change needs to be aware of the destination for the output. If it is a tty, then it is fine to output to a viewer such as less, but otherwise it should go to stdout as before. This should of course not be hardcoded, but use environment variables, e.g., $OE_PAGER || $PAGER || less (inspired by git_pager() in the git source). You should also not expect that everyone wants the options you have used for less. Looking again at how git handles this, they use “LESS=FRX <command>” if the $LESS environment variable is not set, and does not modify it if it is set. You also want to add options such as --paginate and --no-pager (yet again inspired by git) to bitbake.

All in all, look at and be inspired by how git handles pagers, they have this pretty well covered.

//Peter

From: bitbake-devel-bounces@lists.openembedded.org [mailto:bitbake-devel-bounces@lists.openembedded.org] On Behalf Of Burton, Ross
Sent: den 20 juni 2017 12:06
To: Diana Thayer <garbados@gmail.com>
Cc: bitbake-devel <bitbake-devel@lists.openembedded.org>
Subject: Re: [bitbake-devel] [PATCH] bitbake : Paginate 'bitbake -e' using less.


On 20 June 2017 at 05:54, Diana Thayer <garbados@gmail.com<mailto:garbados@gmail.com>> wrote:
+        pager = subprocess.Popen(['less', '-F', '-R', '-S', '-X', '-K'],
+                                 stdin=subprocess.PIPE,
+                                 stdout=sys.stdout,
+                                 universal_newlines=True)

What if I'm piping bitbake -e though grep or into a file already?

Ross

[-- Attachment #2: Type: text/html, Size: 5903 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bitbake : Paginate 'bitbake -e' using less.
  2017-06-20  4:54 Diana Thayer
@ 2017-06-20 10:05 ` Burton, Ross
  2017-06-20 13:39   ` Peter Kjellerstedt
  0 siblings, 1 reply; 6+ messages in thread
From: Burton, Ross @ 2017-06-20 10:05 UTC (permalink / raw)
  To: Diana Thayer; +Cc: bitbake-devel

[-- Attachment #1: Type: text/plain, Size: 405 bytes --]

On 20 June 2017 at 05:54, Diana Thayer <garbados@gmail.com> wrote:

> +        pager = subprocess.Popen(['less', '-F', '-R', '-S', '-X', '-K'],
> +                                 stdin=subprocess.PIPE,
> +                                 stdout=sys.stdout,
> +                                 universal_newlines=True)
>

What if I'm piping bitbake -e though grep or into a file already?

Ross

[-- Attachment #2: Type: text/html, Size: 923 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] bitbake : Paginate 'bitbake -e' using less.
@ 2017-06-20  4:54 Diana Thayer
  2017-06-20 10:05 ` Burton, Ross
  0 siblings, 1 reply; 6+ messages in thread
From: Diana Thayer @ 2017-06-20  4:54 UTC (permalink / raw)
  To: bitbake-devel

This patch modifies bitbake/lib/bb/cooker.py#showEnvironment
to call less using subprocess.Popen, rather than using the logger.
It is a WIP solution to bug 9203.

Signed-off-by: Diana Thayer <garbados@gmail.com>
---
 bitbake/lib/bb/cooker.py | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 479dc5a..eaec040 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -514,21 +514,32 @@ class BBCooker:
                 parselog.exception("Unable to read %s", fn)
                 raise
 
-        # Display history
-        with closing(StringIO()) as env:
-            self.data.inchistory.emit(env)
-            logger.plain(env.getvalue())
-
-        # emit variables and shell functions
-        with closing(StringIO()) as env:
-            data.emit_env(env, envdata, True)
-            logger.plain(env.getvalue())
-
-        # emit the metadata which isnt valid shell
-        data.expandKeys(envdata)
-        for e in sorted(envdata.keys()):
-            if envdata.getVarFlag(e, 'func', False) and envdata.getVarFlag(e, 'python', False):
-                logger.plain("\npython %s () {\n%s}\n", e, envdata.getVar(e, False))
+        # establish `less` as a pager for environment output
+        # TODO determine pager by env var
+        pager = subprocess.Popen(['less', '-F', '-R', '-S', '-X', '-K'],
+                                 stdin=subprocess.PIPE,
+                                 stdout=sys.stdout,
+                                 universal_newlines=True)
+        with pager:
+            lines = []
+            # Display history
+            with closing(StringIO()) as env:
+                self.data.inchistory.emit(env)
+                lines.append(env.getvalue())
+
+            # emit variables and shell functions
+            with closing(StringIO()) as env:
+                data.emit_env(env, envdata, True)
+                lines.append(env.getvalue())
+
+            # emit the metadata which isnt valid shell
+            data.expandKeys(envdata)
+            for e in sorted(envdata.keys()):
+                if envdata.getVarFlag(e, 'func', False) and envdata.getVarFlag(e, 'python', False):
+                    lines.append("\npython %s () {\n%s}\n" % (e, envdata.getVar(e, False)))
+
+            # communicate lines to pager
+            pager.communicate('\n'.join(lines))
 
 
     def buildTaskData(self, pkgs_to_build, task, abort, allowincomplete=False):
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-06-27 13:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-26 21:02 [PATCH] bitbake : Paginate 'bitbake -e' using less Rob Woolley
2017-06-27 13:56 ` Paul Eggleton
  -- strict thread matches above, loose matches on Subject: below --
2017-06-20  4:54 Diana Thayer
2017-06-20 10:05 ` Burton, Ross
2017-06-20 13:39   ` Peter Kjellerstedt
2017-06-26 20:48     ` Diana Thayer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.