From 521c331d986b1361d6877fb007a03233065754ab Mon Sep 17 00:00:00 2001 From: Jesse S Date: Tue, 12 Apr 2022 14:06:41 -0700 Subject: [PATCH] Asadm 2.7.1 bugfix (#171) * fix: TOOLS-1981 --no-color does not remove all ansi symbols * fix: TOOLS-1982 watch cmd does not show tables --- lib/live_cluster/live_cluster_root_controller.py | 4 ++-- lib/view/sheet/decleration.py | 5 +++-- lib/view/sheet/render/column_rsheet.py | 16 ++++++++++------ lib/view/sheet/render/row_rsheet.py | 6 ++++-- lib/view/view.py | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/live_cluster/live_cluster_root_controller.py b/lib/live_cluster/live_cluster_root_controller.py index 73ffa46e..0a15a4ee 100644 --- a/lib/live_cluster/live_cluster_root_controller.py +++ b/lib/live_cluster/live_cluster_root_controller.py @@ -125,8 +125,8 @@ def do_help(self, line): " watch 5 info namespace", ) @DisableAutoComplete() - def do_watch(self, line): - self.view.watch(self, line) + async def do_watch(self, line): + await self.view.watch(self, line) @DisableAutoComplete() @CommandHelp( diff --git a/lib/view/sheet/decleration.py b/lib/view/sheet/decleration.py index 8378320d..11598108 100644 --- a/lib/view/sheet/decleration.py +++ b/lib/view/sheet/decleration.py @@ -14,6 +14,7 @@ from collections import Counter import logging +from typing import Callable from lib.utils import file_size from lib.view import terminal @@ -78,10 +79,10 @@ def __init__( self.vertical_separator = vertical_separator self.horizontal_seperator = horizontal_seperator - self.formatted_vertical_separator = ( + self.formatted_vertical_separator_func: Callable[[], str] = lambda: ( terminal.dim() + vertical_separator + terminal.undim() ) - self.formatted_horizontal_seperator = ( + self.formatted_horizontal_seperator_func: Callable[[], str] = lambda: ( terminal.dim() + horizontal_seperator + terminal.undim() ) self.title_fill = title_fill diff --git a/lib/view/sheet/render/column_rsheet.py b/lib/view/sheet/render/column_rsheet.py index b16dd92f..733fab9f 100644 --- a/lib/view/sheet/render/column_rsheet.py +++ b/lib/view/sheet/render/column_rsheet.py @@ -84,7 +84,7 @@ def do_render(self): # Render fields. title_lines = [ - self.decleration.formatted_vertical_separator.join( + self.decleration.formatted_vertical_separator_func().join( rfield.get_title_line(line_num) for rfield in rfields ) for line_num in range(n_title_lines) @@ -110,7 +110,9 @@ def do_render(self): num_lines += 1 row = [rfield.entry_cell(group_ix, entry_ix) for rfield in rfields] - render.append(self.decleration.formatted_vertical_separator.join(row)) + render.append( + self.decleration.formatted_vertical_separator_func().join(row) + ) if has_aggregates: if self.title_repeat and num_lines % repeats_every == 0: @@ -118,7 +120,9 @@ def do_render(self): num_lines += 1 row = [rfield.aggregate_cell(group_ix) for rfield in rfields] - render.append(self.decleration.formatted_vertical_separator.join(row)) + render.append( + self.decleration.formatted_vertical_separator_func().join(row) + ) self._do_render_n_rows(render, self.n_records) @@ -221,7 +225,7 @@ def get_title_line(self, line_num): line = self.title_lines[line_num] except IndexError: sub_line = line_num - len(self.title_lines) - line = self.rsheet.decleration.formatted_vertical_separator.join( + line = self.rsheet.decleration.formatted_vertical_separator_func().join( sub.get_title_line(sub_line) for sub in self.visible ) @@ -231,12 +235,12 @@ def get_title_line(self, line_num): return terminal.bold() + line + terminal.unbold() def entry_cell(self, group_ix, entry_ix): - return self.rsheet.decleration.formatted_vertical_separator.join( + return self.rsheet.decleration.formatted_vertical_separator_func().join( sub.entry_cell(group_ix, entry_ix) for sub in self.visible ) def aggregate_cell(self, group_ix): - return self.rsheet.decleration.formatted_vertical_separator.join( + return self.rsheet.decleration.formatted_vertical_separator_func().join( sub.aggregate_cell(group_ix) for sub in self.visible ) diff --git a/lib/view/sheet/render/row_rsheet.py b/lib/view/sheet/render/row_rsheet.py index 91e71098..0bd9e43d 100644 --- a/lib/view/sheet/render/row_rsheet.py +++ b/lib/view/sheet/render/row_rsheet.py @@ -178,11 +178,13 @@ def do_render(self): if has_aggregate: row.append(render_field.aggregate_cell(group_ix)) - render.append(self.decleration.formatted_vertical_separator.join(row)) + render.append( + self.decleration.formatted_vertical_separator_func().join(row) + ) if num_groups > 1 and group_ix < num_groups - 1: render.append( - self.decleration.formatted_horizontal_seperator * title_width + self.decleration.formatted_vertical_separator_func() * title_width ) num_rows = len(render_fields) * num_groups - hidden_count diff --git a/lib/view/view.py b/lib/view/view.py index a7c42e1b..085f4fac 100644 --- a/lib/view/view.py +++ b/lib/view/view.py @@ -1169,7 +1169,7 @@ def peekable(peeked, remaining): yield val @staticmethod - def watch(ctrl, line): + async def watch(ctrl, line): diff_highlight = True sleep = 2.0 num_iterations = False @@ -1201,7 +1201,7 @@ def watch(ctrl, line): while True: highlight = False - ctrl.execute(line[:]) + await ctrl.execute(line[:]) output = mystdout.getvalue() mystdout.truncate(0) mystdout.seek(0)