Skip to content

Commit

Permalink
display fixes
Browse files Browse the repository at this point in the history
banner now adjusts to screen as does output
output now keeps at least one space to end of screen to allow for better reading.
  • Loading branch information
bcoca committed Nov 1, 2016
1 parent b42e423 commit d4ac0bd
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/ansible/utils/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ def display(self, msg, color=None, stderr=False, screen_only=False, log_only=Fal
Note: msg *must* be a unicode string to prevent UnicodeError tracebacks.
"""

# FIXME: this needs to be implemented
#msg = utils.sanitize_output(msg)
nocolor = msg
if color:
msg = stringc(msg, color)
Expand Down Expand Up @@ -175,8 +173,6 @@ def debug(self, msg):
self.display("%6d %0.5f: %s" % (os.getpid(), time.time(), msg), color=C.COLOR_DEBUG)

def verbose(self, msg, host=None, caplevel=2):
# FIXME: this needs to be implemented
#msg = utils.sanitize_output(msg)
if self.verbosity > caplevel:
if host is None:
self.display(msg, color=C.COLOR_VERBOSE)
Expand Down Expand Up @@ -222,21 +218,20 @@ def system_warning(self, msg):
if C.SYSTEM_WARNINGS:
self.warning(msg)

def banner(self, msg, color=None):
def banner(self, msg, color=None, cows=True):
'''
Prints a header-looking line with stars taking up to 80 columns
of width (3 columns, minimum)
Prints a header-looking line with cowsay or stars wit hlength depending on terminal width (3 minimum)
'''
if self.b_cowsay:
if self.b_cowsay and cows:
try:
self.banner_cowsay(msg)
return
except OSError:
self.warning("somebody cleverly deleted cowsay or something during the PB run. heh.")

msg = msg.strip()
star_len = (79 - len(msg))
if star_len < 0:
star_len = self.columns - len(msg)
if star_len <= 3:
star_len = 3
stars = u"*" * star_len
self.display(u"\n%s %s" % (msg, stars), color=color)
Expand Down Expand Up @@ -337,4 +332,4 @@ def _set_column_width(self):
tty_size = unpack('HHHH', fcntl.ioctl(0, TIOCGWINSZ, pack('HHHH', 0, 0, 0, 0)))[1]
else:
tty_size = 0
self.columns = max(79, tty_size)
self.columns = max(79, tty_size - 1)

0 comments on commit d4ac0bd

Please sign in to comment.