From 29b8f266ccc8be88d1810ebedc71ad67693576be Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Thu, 15 Nov 2012 21:05:52 +0100 Subject: [PATCH] [equo] fix tty colored output handling, re-add --color --- client/solo/commands/help.py | 5 +++++ client/solo/main.py | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/client/solo/commands/help.py b/client/solo/commands/help.py index 77de584ae..a553ddaba 100644 --- a/client/solo/commands/help.py +++ b/client/solo/commands/help.py @@ -71,6 +71,11 @@ class SoloHelp(SoloCommand): epilog="http://www.sabayon.org", formatter_class=ColorfulFormatter) + # filtered out in solo.main. Will never get here + parser.add_argument( + "--color", action="store_true", + default=None, help=_("force colored output")) + descriptors = SoloCommandDescriptor.obtain() descriptors.sort(key = lambda x: x.get_name()) group = parser.add_argument_group("command", "available commands") diff --git a/client/solo/main.py b/client/solo/main.py index 694d3b1c5..7491a05c9 100644 --- a/client/solo/main.py +++ b/client/solo/main.py @@ -18,7 +18,8 @@ import pdb from entropy.i18n import _ from entropy.output import print_error, print_warning, bold, purple, \ - teal, blue, darkred, darkgreen, readtext, print_generic, TextInterface + teal, blue, darkred, darkgreen, readtext, print_generic, TextInterface, \ + is_stdout_a_tty, nocolor from entropy.const import etpConst, const_convert_to_rawstring, \ const_debug_enabled from entropy.exceptions import SystemDatabaseError, OnlineMirrorError, \ @@ -249,6 +250,13 @@ def warn_live_system(): def main(): + is_color = "--color" in sys.argv + if is_color: + sys.argv.remove("--color") + + if not is_color and not is_stdout_a_tty(): + nocolor() + warn_version_mismatch() install_exception_handler()