[equo] fix tty colored output handling, re-add --color

This commit is contained in:
Fabio Erculiani
2012-11-15 21:05:52 +01:00
parent 281c9b5bcf
commit 29b8f266cc
2 changed files with 14 additions and 1 deletions
+5
View File
@@ -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")
+9 -1
View File
@@ -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()