From b0f398caaa3b783fc605875614da50a2a2c8ef9b Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 7 Aug 2014 12:30:01 -0400 Subject: [PATCH] Resolves #386, tty width on jenkins Signed-off-by: Daniel Nephin --- fig/cli/formatter.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fig/cli/formatter.py b/fig/cli/formatter.py index 3d7e2d517..ee4b3d959 100644 --- a/fig/cli/formatter.py +++ b/fig/cli/formatter.py @@ -4,11 +4,17 @@ import os import texttable +def get_tty_width(): + tty_size = os.popen('stty size', 'r').read().split() + if len(tty_size) != 2: + return 80 + _, width = tty_size + return width + + class Formatter(object): def table(self, headers, rows): - height, width = os.popen('stty size', 'r').read().split() - - table = texttable.Texttable(max_width=width) + table = texttable.Texttable(max_width=get_tty_width()) table.set_cols_dtype(['t' for h in headers]) table.add_rows([headers] + rows) table.set_deco(table.HEADER)