From 8b0247e97fe5a0aef5e4eb1c13f14759dd74d7be Mon Sep 17 00:00:00 2001 From: angelopoerio Date: Sat, 20 Aug 2016 17:49:13 +0200 Subject: [PATCH] improved aligment of UI and indentation of Python code --- glances/outputs/static/html/plugins/irq.html | 4 +- glances/outputs/static/html/stats.html | 5 +- glances/plugins/glances_help.py | 21 +++----- glances/plugins/glances_irq.py | 56 +++++++++++--------- unitest-xmlrpc.py | 2 +- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/glances/outputs/static/html/plugins/irq.html b/glances/outputs/static/html/plugins/irq.html index 50eb5406..8b2aa606 100644 --- a/glances/outputs/static/html/plugins/irq.html +++ b/glances/outputs/static/html/plugins/irq.html @@ -1,8 +1,10 @@
IRQ
+
Rate/s
{{irq.irq_line}}
-
{{irq.irq_rate}}
+
+
{{irq.irq_rate}}
diff --git a/glances/outputs/static/html/stats.html b/glances/outputs/static/html/stats.html index 5aee5b02..2974822e 100644 --- a/glances/outputs/static/html/stats.html +++ b/glances/outputs/static/html/stats.html @@ -49,10 +49,9 @@
-
-
-
+
+
diff --git a/glances/plugins/glances_help.py b/glances/plugins/glances_help.py index 5369927c..109fef58 100644 --- a/glances/plugins/glances_help.py +++ b/glances/plugins/glances_help.py @@ -50,16 +50,16 @@ class Plugin(GlancesPlugin): pass def generate_view_data(self): - self.view_data['version'] = '{} {}'.format(__appname__.title(), __version__) - self.view_data['psutil_version'] = ' with PSutil {}'.format(psutil_version) + self.view_data['version'] = '{0} {1}'.format(__appname__.title(), __version__) + self.view_data['psutil_version'] = ' with PSutil {0}'.format(psutil_version) try: - self.view_data['configuration_file'] = 'Configuration file: {}'.format(self.config.loaded_config_file) + self.view_data['configuration_file'] = 'Configuration file: {0}'.format(self.config.loaded_config_file) except AttributeError: pass - msg_col = ' {:1} {:35}' - msg_col2 = ' {:1} {:35}' + msg_col = ' {0:1} {1:35}' + msg_col2 = ' {0:1} {1:35}' self.view_data['sort_auto'] = msg_col.format('a', 'Sort processes automatically') self.view_data['sort_network'] = msg_col2.format('b', 'Bytes or bits for network I/O') self.view_data['sort_cpu'] = msg_col.format('c', 'Sort processes by CPU%') @@ -74,8 +74,8 @@ class Plugin(GlancesPlugin): self.view_data['sort_cpu_times'] = msg_col.format('t', 'Sort processes by TIME') self.view_data['show_hide_help'] = msg_col2.format('h', 'Show/hide this help screen') self.view_data['show_hide_diskio'] = msg_col.format('d', 'Show/hide disk I/O stats') - self.view_data['show_hide_irq'] = msg_col2.format('R', 'Show/hide IRQ stats') - self.view_data['view_network_io_combination'] = msg_col2.format('T', 'View network I/O as combination') + self.view_data['show_hide_irq'] = msg_col2.format('R', 'Show/hide IRQ stats') + self.view_data['view_network_io_combination'] = msg_col2.format('T', 'View network I/O as combination') self.view_data['show_hide_filesystem'] = msg_col.format('f', 'Show/hide filesystem stats') self.view_data['view_cumulative_network'] = msg_col2.format('U', 'View cumulative network I/O') self.view_data['show_hide_network'] = msg_col.format('n', 'Show/hide network stats') @@ -94,8 +94,6 @@ class Plugin(GlancesPlugin): self.view_data['show_hide_ip'] = msg_col2.format('I', 'Show/hide IP module') self.view_data['diskio_iops'] = msg_col2.format('B', 'Count/rate for Disk I/O') self.view_data['show_hide_top_menu'] = msg_col2.format('5', 'Show/hide top menu (QL, CPU, MEM, SWAP and LOAD)') - self.view_data['show_hide_amp'] = msg_col2.format('A', 'Show/hide AMP plugin') - self.view_data['enable_disable_ports'] = msg_col.format('P', 'Enable/disable ports plugin') self.view_data['edit_pattern_filter'] = 'ENTER: Edit the process filter pattern' def get_view_data(self, args=None): @@ -167,14 +165,11 @@ class Plugin(GlancesPlugin): ret.append(self.curse_add_line(self.view_data['show_hide_top_menu'])) ret.append(self.curse_new_line()) ret.append(self.curse_add_line(self.view_data['enable_disable_short_processname'])) - ret.append(self.curse_add_line(self.view_data['show_hide_amp'])) + ret.append(self.curse_add_line(self.view_data['show_hide_irq'])) ret.append(self.curse_new_line()) ret.append(self.curse_add_line(self.view_data['enable_disable_irix'])) ret.append(self.curse_add_line(self.view_data['quit'])) ret.append(self.curse_new_line()) - ret.append(self.curse_add_line(self.view_data['enable_disable_ports'])) - ret.append(self.curse_add_line(self.view_data['show_hide_irq'])) - ret.append(self.curse_new_line()) ret.append(self.curse_new_line()) diff --git a/glances/plugins/glances_irq.py b/glances/plugins/glances_irq.py index af943150..5a1eec7d 100644 --- a/glances/plugins/glances_irq.py +++ b/glances/plugins/glances_irq.py @@ -38,7 +38,7 @@ class Plugin(GlancesPlugin): # We want to display the stat in the curse interface self.display_curse = True - self.lasts = {} + self.lasts = {} # Init the stats self.reset() @@ -58,40 +58,44 @@ class Plugin(GlancesPlugin): # Reset the list self.reset() - if self.input_method == 'local': - with open('/proc/interrupts') as irq_proc: - time_since_update = getTimeSinceLastUpdate('irq') - irq_proc.readline() # skip header line - for irq_line in irq_proc.readlines(): - splitted_line = irq_line.split() - irq_line = splitted_line[0].replace(':','') - current_irqs = sum([int(count) for count in splitted_line[1:] if count.isdigit()]) # sum interrupts on all CPUs - irq_rate = int(current_irqs - self.lasts.get(irq_line) if self.lasts.get(irq_line) else 0 // time_since_update) - irq_current = { - 'irq_line': irq_line, - 'irq_rate': irq_rate, - 'key': self.get_key(), - 'time_since_update': time_since_update - } - self.stats.append(irq_current) - self.lasts[irq_line] = current_irqs + if self.input_method == 'local': + with open('/proc/interrupts') as irq_proc: + time_since_update = getTimeSinceLastUpdate('irq') + irq_proc.readline() # skip header line + for irq_line in irq_proc.readlines(): + splitted_line = irq_line.split() + irq_line = splitted_line[0].replace(':', '') + current_irqs = sum([int(count) for count in splitted_line[ + 1:] if count.isdigit()]) # sum interrupts on all CPUs + irq_rate = int( + current_irqs - + self.lasts.get(irq_line) if self.lasts.get(irq_line) else 0 // + time_since_update) + irq_current = { + 'irq_line': irq_line, + 'irq_rate': irq_rate, + 'key': self.get_key(), + 'time_since_update': time_since_update + } + self.stats.append(irq_current) + self.lasts[irq_line] = current_irqs - elif self.input_method == 'snmp': - # not available - pass + elif self.input_method == 'snmp': + # not available + pass # Update the view self.update_views() - self.stats = sorted(self.stats, key=operator.itemgetter('irq_rate'), reverse=True)[:5] # top 5 IRQ by rate/s - return self.stats + self.stats = sorted(self.stats, key=operator.itemgetter( + 'irq_rate'), reverse=True)[:5] # top 5 IRQ by rate/s + return self.stats def update_views(self): """Update stats views.""" # Call the father's method super(Plugin, self).update_views() - def msg_curse(self, args=None, max_width=None): """Return the dict to display in the curse interface.""" # Init the return message @@ -110,14 +114,14 @@ class Plugin(GlancesPlugin): # Header msg = '{:{width}}'.format('IRQ', width=irq_max_width) ret.append(self.curse_add_line(msg, "TITLE")) - msg = '{:>7}'.format('Rate/s') + msg = '{:>14}'.format('Rate/s') ret.append(self.curse_add_line(msg)) for i in self.stats: ret.append(self.curse_new_line()) msg = '{:>3}'.format(i['irq_line']) ret.append(self.curse_add_line(msg)) - msg = '{:>12}'.format(str(i['irq_rate'])) + msg = '{:>20}'.format(str(i['irq_rate'])) ret.append(self.curse_add_line(msg)) return ret diff --git a/unitest-xmlrpc.py b/unitest-xmlrpc.py index 55211790..c57edc82 100755 --- a/unitest-xmlrpc.py +++ b/unitest-xmlrpc.py @@ -176,7 +176,7 @@ class TestGlances(unittest.TestCase): self.assertIsInstance(req['cpu'], dict) def test_012_irq(self): - """IRQS""" + """IRQS""" method = "getIrqs()" print('INFO: [TEST_012] Method: %s' % method) req = json.loads(client.getIrq())