blue on black, tears on a river, push on a shove, it don't mean much

(make colorized playbook runs not suck on black terminals)
This commit is contained in:
Michael DeHaan 2012-07-25 20:29:20 -04:00
parent 2030f82bf2
commit e035ce97ce
3 changed files with 6 additions and 7 deletions

View file

@ -31,9 +31,7 @@ from ansible.color import ANSIBLE_COLOR, stringc
def colorize(lead, num, color):
""" Print 'lead' = 'num' in 'color' """
if num == 0:
color='black';
if ANSIBLE_COLOR:
if num != 0 and ANSIBLE_COLOR:
return "%s%s%-15s" % (stringc(lead, color), stringc("=", color), stringc(str(num), color))
else:
return "%s=%-4s" % (lead, str(num))

View file

@ -328,12 +328,12 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
if self._async_notified[jid] > clock:
self._async_notified[jid] = clock
msg = "<job %s> polling, %ss remaining"%(jid, clock)
print stringc(msg, 'blue')
print stringc(msg, 'cyan')
def on_async_ok(self, host, res, jid):
msg = "<job %s> finished on %s"%(jid, host)
print stringc(msg, 'blue')
print stringc(msg, 'cyan')
def on_async_failed(self, host, res, jid):
@ -379,12 +379,12 @@ class PlaybookCallbacks(object):
def on_import_for_host(self, host, imported_file):
msg = "%s: importing %s" % (host, imported_file)
print stringc(msg, 'blue')
print stringc(msg, 'cyan')
def on_not_import_for_host(self, host, missing_file):
msg = "%s: not importing file: %s" % (host, missing_file)
print stringc(msg, 'blue')
print stringc(msg, 'cyan')
def on_play_start(self, pattern):

View file

@ -40,6 +40,7 @@ codeCodes = {
'blue': '0;34', 'white': '1;37',
'green': '0;32', 'bright blue': '1;34',
'cyan': '0;36', 'bright green': '1;32',
# 'cyan': '0;32', 'bright green': '1;32',
'red': '0;31', 'bright cyan': '1;36',
'purple': '0;35', 'bright red': '1;31',
'yellow': '0;33', 'bright purple': '1;35',