Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1463535 > unrolled thread
| Started by | Valentin Rothberg <valentinrothberg@gmail.com> |
|---|---|
| First post | 2016-08-16 10:30 +0200 |
| Last post | 2016-08-16 12:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v2] checkkconfigsymbols.py: add --no-color option, don't print color to non-TTY Valentin Rothberg <valentinrothberg@gmail.com> - 2016-08-16 10:30 +0200
Re: [PATCH v2] checkkconfigsymbols.py: add --no-color option, don't print color to non-TTY Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-08-16 12:50 +0200
| From | Valentin Rothberg <valentinrothberg@gmail.com> |
|---|---|
| Date | 2016-08-16 10:30 +0200 |
| Subject | Re: [PATCH v2] checkkconfigsymbols.py: add --no-color option, don't print color to non-TTY |
| Message-ID | <s6HUZ-EP-13@gated-at.bofh.it> |
Hi Greg,
could you pick up this patch?
On Tue, Jul 5, 2016 at 9:47 AM, Andrew Donnellan
<andrew.donnellan@au1.ibm.com> wrote:
> Only print the ANSI colour escape codes if stdout is a TTY. Useful if
> redirecting output to a file or piping to another script.
>
> Also add a new option, --no-color, if the user wants to disable colour
> output for whatever reason.
>
> Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Valentin Rothberg <valentinrothberg@gmail.com>
> ---
>
> V1->V2:
> - automatically detect non-TTYs and disable colour output.
> Suggested by Josh Triplett
> ---
> scripts/checkkconfigsymbols.py | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
> index df643f6..b140fc9 100755
> --- a/scripts/checkkconfigsymbols.py
> +++ b/scripts/checkkconfigsymbols.py
> @@ -82,6 +82,11 @@ def parse_options():
> default=False,
> help="Reset current Git tree even when it's dirty.")
>
> + parser.add_option('', '--no-color', dest='color', action='store_false',
> + default=True,
> + help="Don't print colored output. Default when not "
> + "outputting to a terminal.")
> +
> (opts, _) = parser.parse_args()
>
> if opts.commit and opts.diff:
> @@ -116,6 +121,9 @@ def main():
> """Main function of this module."""
> opts = parse_options()
>
> + global color
> + color = opts.color and sys.stdout.isatty()
> +
> if opts.sim and not opts.commit and not opts.diff:
> sims = find_sims(opts.sim, opts.ignore)
> if sims:
> @@ -202,14 +210,14 @@ def yel(string):
> """
> Color %string yellow.
> """
> - return "\033[33m%s\033[0m" % string
> + return "\033[33m%s\033[0m" % string if color else string
>
>
> def red(string):
> """
> Color %string red.
> """
> - return "\033[31m%s\033[0m" % string
> + return "\033[31m%s\033[0m" % string if color else string
>
>
> def execute(cmd):
> --
> Andrew Donnellan OzLabs, ADL Canberra
> andrew.donnellan@au1.ibm.com IBM Australia Limited
>
[toc] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-08-16 12:50 +0200 |
| Message-ID | <s6K6u-1XD-23@gated-at.bofh.it> |
| In reply to | #1463535 |
On Tue, Aug 16, 2016 at 10:25:48AM +0200, Valentin Rothberg wrote: > Hi Greg, > > could you pick up this patch? > > On Tue, Jul 5, 2016 at 9:47 AM, Andrew Donnellan > <andrew.donnellan@au1.ibm.com> wrote: > > Only print the ANSI colour escape codes if stdout is a TTY. Useful if > > redirecting output to a file or piping to another script. > > > > Also add a new option, --no-color, if the user wants to disable colour > > output for whatever reason. > > > > Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> > > Acked-by: Valentin Rothberg <valentinrothberg@gmail.com> It's in my very long "to-review" queue, it's not lost, just seems like it... thanks, greg k-h
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web