From 42356c45b371c82268fd994b1acfe3a061a58608 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Wed, 28 Dec 2016 18:41:46 +0100 Subject: [PATCH] Refactor display method of the curses interface sprint 3 --- glances/outputs/glances_curses.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index 0353bc44..8aa758cc 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -687,24 +687,13 @@ class _GlancesCurses(object): plugin_display_optional[p] = True if stats_number > 1: self.space_between_column = max(1, int((self.screen.getmaxyx()[1] - stats_width) / (stats_number - 1))) - # No space ? Remove optionnal MEM stats - if self.space_between_column < 3: - plugin_display_optional['mem'] = False - if self.args.disable_mem: - plugin_widths['mem'] = 0 - else: - plugin_widths['mem'] = self.get_stats_display_width(stat_display["mem"], without_option=True) - stats_width = sum(itervalues(plugin_widths)) + 1 - self.space_between_column = max(1, int((self.screen.getmaxyx()[1] - stats_width) / (stats_number - 1))) - # No space again ? Remove optionnal CPU stats - if self.space_between_column < 3: - plugin_display_optional['cpu'] = False - if self.args.disable_cpu: - plugin_widths['cpu'] = 0 - else: - plugin_widths['cpu'] = self.get_stats_display_width(stat_display["cpu"], without_option=True) - stats_width = sum(itervalues(plugin_widths)) + 1 - self.space_between_column = max(1, int((self.screen.getmaxyx()[1] - stats_width) / (stats_number - 1))) + for p in ['mem', 'cpu']: + # No space ? Remove optional stats + if self.space_between_column < 3: + plugin_display_optional[p] = False + plugin_widths[p] = self.get_stats_display_width(stat_display[p], without_option=True) if hasattr(self.args, 'disable_' + p) else 0 + stats_width = sum(itervalues(plugin_widths)) + 1 + self.space_between_column = max(1, int((self.screen.getmaxyx()[1] - stats_width) / (stats_number - 1))) else: self.space_between_column = 0