From bb872863f909c524298e5f4d660ec181c7db9bca Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sun, 30 Dec 2018 17:17:15 +0000 Subject: [PATCH] Try to slightly clean up table rendering in the CLI. --- volatility/cli/__init__.py | 2 +- volatility/cli/text_renderer.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/volatility/cli/__init__.py b/volatility/cli/__init__.py index 5023641e5..c662d7f8c 100644 --- a/volatility/cli/__init__.py +++ b/volatility/cli/__init__.py @@ -71,7 +71,7 @@ class PrintedProgress(object): message = "\rProgress: {0: 7.2f}\t\t{1:}".format(round(progress, 2), description or '') message_len = len(message) self._max_message_len = max([self._max_message_len, message_len]) - print(message, end = ' ' * (self._max_message_len - message_len)) + print(message, end = (' ' * (self._max_message_len - message_len)) + '\r') class MuteProgress(PrintedProgress): diff --git a/volatility/cli/text_renderer.py b/volatility/cli/text_renderer.py index 4eb065276..749b84922 100644 --- a/volatility/cli/text_renderer.py +++ b/volatility/cli/text_renderer.py @@ -135,18 +135,21 @@ class QuickTextRenderer(interfaces.renderers.Renderer): # TODO: Improve text output outfd = sys.stdout + line = [] for column in grid.columns: # Ignore the type because namedtuples don't realize they have accessible attributes - outfd.write("\t{}".format(column.name)) # type: ignore - outfd.write("\n") + line.append("{}".format(column.name)) + outfd.write("\n{}\n".format("\t".join(line))) def visitor(node, accumulator): accumulator.write("\n") # Nodes always have a path value, giving them a path_depth of at least 1, we use max just in case accumulator.write("*" * max(0, node.path_depth - 1)) + line = [] for column in grid.columns: renderer = self.type_renderers.get(column.type, self.type_renderers['default']) - accumulator.write("\t" + renderer(node.values[column.index])) + line.append(renderer(node.values[column.index])) + accumulator.write("{}".format("\t".join(line))) return accumulator grid.populate(visitor, outfd)