From af0bd37744cb241d05f19ef5db402df21ff8182b Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Mon, 11 May 2015 16:55:55 +0200 Subject: [PATCH] flake8 - import statements are in the wrong order. - missing whitespace around arithmetic operator - blind except: statement - multiple imports on one line - trailing whitespace - blank line contains whitespace - line break before binary operator - missing whitespace after ',' - block comment should start with '# ' - multiple spaces before operator - 'logger' imported but unused - expected 2 blank lines, found 1 --- glances/__init__.py | 1 + glances/core/glances_actions.py | 5 +- glances/core/glances_cpu_percent.py | 4 +- glances/core/glances_processes.py | 8 ++-- glances/core/glances_stats.py | 4 +- glances/exports/glances_csv.py | 4 +- glances/exports/glances_influxdb.py | 2 +- glances/exports/glances_rabbitmq.py | 13 +++-- glances/outputs/glances_bars.py | 2 +- glances/outputs/glances_bottle.py | 18 +++---- glances/outputs/glances_curses.py | 15 +++--- glances/plugins/glances_core.py | 4 +- glances/plugins/glances_cpu.py | 7 ++- glances/plugins/glances_diskio.py | 5 +- glances/plugins/glances_docker.py | 4 +- glances/plugins/glances_fs.py | 3 +- glances/plugins/glances_hddtemp.py | 2 +- glances/plugins/glances_help.py | 60 ++++++++++++------------ glances/plugins/glances_mem.py | 6 +-- glances/plugins/glances_memswap.py | 11 +++-- glances/plugins/glances_monitor.py | 1 - glances/plugins/glances_network.py | 16 +++---- glances/plugins/glances_percpu.py | 4 +- glances/plugins/glances_plugin.py | 2 +- glances/plugins/glances_psutilversion.py | 4 +- glances/plugins/glances_quicklook.py | 7 ++- glances/plugins/glances_uptime.py | 6 +-- 27 files changed, 113 insertions(+), 105 deletions(-) diff --git a/glances/__init__.py b/glances/__init__.py index 61ddd781..a195f788 100644 --- a/glances/__init__.py +++ b/glances/__init__.py @@ -59,6 +59,7 @@ if psutil_version < psutil_min_version: print('PSutil 2.0 or higher is needed. Glances cannot start.') sys.exit(1) + def __signal_handler(signal, frame): """Callback for CTRL-C.""" end() diff --git a/glances/core/glances_actions.py b/glances/core/glances_actions.py index f7e6f7e2..3fba9ec1 100644 --- a/glances/core/glances_actions.py +++ b/glances/core/glances_actions.py @@ -19,11 +19,12 @@ """Manage on alert actions.""" +# Import system lib +from subprocess import Popen + # Import Glances lib from glances.core.glances_logging import logger -# Import system lib -from subprocess import Popen try: import pystache except ImportError: diff --git a/glances/core/glances_cpu_percent.py b/glances/core/glances_cpu_percent.py index c55b7f86..9488d8d4 100644 --- a/glances/core/glances_cpu_percent.py +++ b/glances/core/glances_cpu_percent.py @@ -19,10 +19,10 @@ """CPU percent stats shared between CPU and Quicklook plugins.""" -import psutil - from glances.core.glances_timer import Timer +import psutil + class CpuPercent(object): diff --git a/glances/core/glances_processes.py b/glances/core/glances_processes.py index 6c001be5..34a786ae 100644 --- a/glances/core/glances_processes.py +++ b/glances/core/glances_processes.py @@ -22,13 +22,13 @@ import collections import os import re -# Import psutil -import psutil - # Import Glances lib from glances.core.glances_globals import is_bsd, is_linux, is_mac, is_windows from glances.core.glances_logging import logger -from glances.core.glances_timer import getTimeSinceLastUpdate, Timer +from glances.core.glances_timer import Timer, getTimeSinceLastUpdate + +# Import psutil +import psutil def is_kernel_thread(proc): diff --git a/glances/core/glances_stats.py b/glances/core/glances_stats.py index 61cbc90b..1f039eb6 100644 --- a/glances/core/glances_stats.py +++ b/glances/core/glances_stats.py @@ -25,7 +25,7 @@ import re import sys import threading -from glances.core.glances_globals import plugins_path, exports_path, sys_path +from glances.core.glances_globals import exports_path, plugins_path, sys_path from glances.core.glances_logging import logger # SNMP OID regexp pattern to short system name dict @@ -152,7 +152,7 @@ class GlancesStats(object): # For standalone and server modes # For each plugins, call the update method for p in self._plugins: - # logger.debug("Update %s stats" % p) + # logger.debug("Update %s stats" % p) self._plugins[p].update() def export(self, input_stats=None): diff --git a/glances/exports/glances_csv.py b/glances/exports/glances_csv.py index 2b450027..1be95bf9 100644 --- a/glances/exports/glances_csv.py +++ b/glances/exports/glances_csv.py @@ -80,7 +80,7 @@ class Export(GlancesExport): # First line: header if self.first_line: fieldnames = item.keys() - csv_header += map(lambda x: plugin+'_'+item[item['key']]+'_'+x, item) + csv_header += map(lambda x: plugin + '_' + item[item['key']] + '_' + x, item) # Others lines: stats fieldvalues = item.values() csv_data += fieldvalues @@ -88,7 +88,7 @@ class Export(GlancesExport): # First line: header if self.first_line: fieldnames = all_stats[i].keys() - csv_header += map(lambda x: plugin+'_'+x, fieldnames) + csv_header += map(lambda x: plugin + '_' + x, fieldnames) # Others lines: stats fieldvalues = all_stats[i].values() csv_data += fieldvalues diff --git a/glances/exports/glances_influxdb.py b/glances/exports/glances_influxdb.py index bab01bdc..bbc9a2b1 100644 --- a/glances/exports/glances_influxdb.py +++ b/glances/exports/glances_influxdb.py @@ -103,7 +103,7 @@ class Export(GlancesExport): password=self.password, database=self.db) get_all_db = [i['name'] for i in db.get_list_database()] - except: + except Exception: logger.critical("Can not connect to InfluxDB database '%s' (%s)" % (self.db, e)) sys.exit(2) diff --git a/glances/exports/glances_rabbitmq.py b/glances/exports/glances_rabbitmq.py index c0400883..ce185428 100644 --- a/glances/exports/glances_rabbitmq.py +++ b/glances/exports/glances_rabbitmq.py @@ -20,7 +20,9 @@ """JMS interface class.""" # Import sys libs -import sys, socket, datetime +import datetime +import socket +import sys from numbers import Number # Import Glances lib @@ -82,7 +84,11 @@ class Export(GlancesExport): if not self.export_enable: return None try: - parameters = pika.URLParameters("amqp://"+self.rabbitmq_user+":"+self.rabbitmq_password+"@"+self.rabbitmq_host+":"+self.rabbitmq_port+"/") + parameters = pika.URLParameters( + 'amqp://' + self.rabbitmq_user + + ':' + self.rabbitmq_password + + '@' + self.rabbitmq_host + + ':' + self.rabbitmq_port + '/') connection = pika.BlockingConnection(parameters) channel = connection.channel() return channel @@ -92,7 +98,8 @@ class Export(GlancesExport): def export(self, name, columns, points): """Write the points in RabbitMQ.""" - data = "hostname="+self.hostname+", name="+name+", dateinfo="+datetime.datetime.utcnow().isoformat() + data = ('hostname=' + self.hostname + ', name=' + name + + ', dateinfo=' + datetime.datetime.utcnow().isoformat()) for i in range(0, len(columns)): if not isinstance(points[i], Number): continue diff --git a/glances/outputs/glances_bars.py b/glances/outputs/glances_bars.py index e9a9d98e..c25924f1 100644 --- a/glances/outputs/glances_bars.py +++ b/glances/outputs/glances_bars.py @@ -20,8 +20,8 @@ """Manage bars for Glances output.""" # Import system lib -from math import modf import locale +from math import modf class Bar(object): diff --git a/glances/outputs/glances_bottle.py b/glances/outputs/glances_bottle.py index 7d205cfe..a7b60831 100644 --- a/glances/outputs/glances_bottle.py +++ b/glances/outputs/glances_bottle.py @@ -59,12 +59,12 @@ class GlancesBottle(object): """Define route.""" self._app.route('/', method="GET", callback=self._index) self._app.route('/', method=["GET", "POST"], callback=self._index) - + self._app.route('/', method="GET", callback=self._css) self._app.route('/', method="GET", callback=self._js) self._app.route('/', method="GET", callback=self._js_map) self._app.route('/', method="GET", callback=self._html) - + self._app.route('/', method="GET", callback=self._images) self._app.route('/favicon.ico', method="GET", callback=self._favicon) @@ -114,7 +114,7 @@ class GlancesBottle(object): """Bottle callback for *.html files.""" # Return the static file return static_file(filename, root=os.path.join(self.STATIC_PATH, 'html')) - + def _css(self, filename): """Bottle callback for *.css files.""" # Return the static file @@ -134,7 +134,7 @@ class GlancesBottle(object): """Bottle callback for *.png files.""" # Return the static file return static_file(filename, root=os.path.join(self.STATIC_PATH, 'images')) - + def _favicon(self): """Bottle callback for favicon.""" # Return the static file @@ -153,8 +153,8 @@ class GlancesBottle(object): plist = json.dumps(view_data, sort_keys=True) except Exception as e: abort(404, "Cannot get help view data (%s)" % str(e)) - return plist - + return plist + def _api_plugins(self): """ @api {get} /api/2/pluginslist Get plugins list @@ -204,7 +204,7 @@ class GlancesBottle(object): if not self.args.debug: # Update the stat self.stats.update() - + try: # Get the JSON value of the stat ID statval = json.dumps(self.stats.getAllAsDict()) @@ -213,10 +213,10 @@ class GlancesBottle(object): return statval else: path = "~/glances/" - if is_windows: + if is_windows: path = "D:\\glances\\" filepath = path + "debug.json" - + f = open(filepath) return f.read() diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index 1cea0098..5b74ea5c 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -20,8 +20,8 @@ """Curses interface class.""" # Import system lib -import sys import re +import sys # Import Glances lib from glances.core.glances_globals import is_mac, is_windows @@ -570,10 +570,9 @@ class _GlancesCurses(object): # Display left sidebar (NETWORK+DISKIO+FS+SENSORS+Current time) # ================================================================== self.init_column() - if (not (self.args.disable_network and self.args.disable_diskio - and self.args.disable_fs and self.args.disable_raid - and self.args.disable_sensors)) \ - and not self.args.disable_left_sidebar: + if not (self.args.disable_network and self.args.disable_diskio and + self.args.disable_fs and self.args.disable_raid and + self.args.disable_sensors) and not self.args.disable_left_sidebar: self.new_line() self.display_plugin(stats_network) self.new_line() @@ -875,11 +874,11 @@ class _GlancesCurses(object): try: if without_option: # Size without options - c = len(max(''.join([(re.sub(r'[^\x00-\x7F]+',' ', i['msg']) if not i['optional'] else "") + c = len(max(''.join([(re.sub(r'[^\x00-\x7F]+', ' ', i['msg']) if not i['optional'] else "") for i in curse_msg['msgdict']]).split('\n'), key=len)) else: # Size with all options - c = len(max(''.join([re.sub(r'[^\x00-\x7F]+',' ', i['msg']) + c = len(max(''.join([re.sub(r'[^\x00-\x7F]+', ' ', i['msg']) for i in curse_msg['msgdict']]).split('\n'), key=len)) except Exception: return 0 @@ -1077,7 +1076,7 @@ class GlancesCursesBrowser(_GlancesCurses): return False # Display the Glances server list - #================================ + # ================================ # Table of table # Item description: [stats_id, column name, column size] diff --git a/glances/plugins/glances_core.py b/glances/plugins/glances_core.py index 5a91c5b2..4dce71c5 100644 --- a/glances/plugins/glances_core.py +++ b/glances/plugins/glances_core.py @@ -19,10 +19,10 @@ """CPU core plugin.""" -import psutil - from glances.plugins.glances_plugin import GlancesPlugin +import psutil + class Plugin(GlancesPlugin): diff --git a/glances/plugins/glances_cpu.py b/glances/plugins/glances_cpu.py index 06750eeb..52e81a62 100644 --- a/glances/plugins/glances_cpu.py +++ b/glances/plugins/glances_cpu.py @@ -19,11 +19,10 @@ """CPU plugin.""" -import psutil - -from glances.plugins.glances_plugin import GlancesPlugin from glances.core.glances_cpu_percent import cpu_percent -# from glances.core.glances_logging import logger +from glances.plugins.glances_plugin import GlancesPlugin + +import psutil # SNMP OID # percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0 diff --git a/glances/plugins/glances_diskio.py b/glances/plugins/glances_diskio.py index bb45cb1a..25b2bfe7 100644 --- a/glances/plugins/glances_diskio.py +++ b/glances/plugins/glances_diskio.py @@ -21,12 +21,13 @@ import operator -import psutil - # Import Glances libs from glances.core.glances_timer import getTimeSinceLastUpdate from glances.plugins.glances_plugin import GlancesPlugin +import psutil + + # Define the history items list # All items in this list will be historised if the --enable-history tag is set # 'color' define the graph color in #RGB format diff --git a/glances/plugins/glances_docker.py b/glances/plugins/glances_docker.py index 4ea1203f..5ee72b33 100644 --- a/glances/plugins/glances_docker.py +++ b/glances/plugins/glances_docker.py @@ -24,8 +24,8 @@ import os import re # Import Glances libs -from glances.core.glances_timer import getTimeSinceLastUpdate from glances.core.glances_logging import logger +from glances.core.glances_timer import getTimeSinceLastUpdate from glances.plugins.glances_plugin import GlancesPlugin # Docker-py library (optional and Linux-only) @@ -172,7 +172,7 @@ class Plugin(GlancesPlugin): try: # self.docker_stats[c['Id']] = self.docker_client.stats(c['Id'], decode=True) all_stats = self.docker_stats[c['Id']].next() - except: + except Exception: all_stats = {} c['cpu'] = self.get_docker_cpu(c['Id'], all_stats) diff --git a/glances/plugins/glances_fs.py b/glances/plugins/glances_fs.py index b06e8225..cb488143 100644 --- a/glances/plugins/glances_fs.py +++ b/glances/plugins/glances_fs.py @@ -21,9 +21,10 @@ import operator +from glances.plugins.glances_plugin import GlancesPlugin + import psutil -from glances.plugins.glances_plugin import GlancesPlugin # SNMP OID # The snmpd.conf needs to be edited. diff --git a/glances/plugins/glances_hddtemp.py b/glances/plugins/glances_hddtemp.py index f697efa9..972dba4f 100644 --- a/glances/plugins/glances_hddtemp.py +++ b/glances/plugins/glances_hddtemp.py @@ -24,8 +24,8 @@ import os import socket # Import Glances libs -from glances.plugins.glances_plugin import GlancesPlugin from glances.core.glances_logging import logger +from glances.plugins.glances_plugin import GlancesPlugin class Plugin(GlancesPlugin): diff --git a/glances/plugins/glances_help.py b/glances/plugins/glances_help.py index ef9db5c0..63a1425e 100644 --- a/glances/plugins/glances_help.py +++ b/glances/plugins/glances_help.py @@ -61,36 +61,36 @@ class Plugin(GlancesPlugin): 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%') - self.view_data['show_hide_alert'] = msg_col2.format("l", 'Show/hide alert logs') - self.view_data['sort_mem'] = msg_col.format("m", 'Sort processes by MEM%') - self.view_data['sort_user'] = msg_col.format("u", 'Sort processes by USER') - self.view_data['delete_warning_alerts'] = msg_col2.format("w", 'Delete warning alerts') - self.view_data['sort_proc'] = msg_col.format("p", 'Sort processes by name') - self.view_data['delete_warning_critical_alerts'] = msg_col2.format("x", 'Delete warning and critical alerts') - self.view_data['sort_io'] = msg_col.format("i", 'Sort processes by I/O rate') - self.view_data['percpu'] = msg_col2.format("1", 'Global CPU or per-CPU stats') - 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['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') - self.view_data['show_hide_filesytem_freespace'] = msg_col2.format("F", 'Show filesystem free space') - self.view_data['show_hide_sensors'] = msg_col.format("s", 'Show/hide sensors stats') - self.view_data['generate_graphs'] = msg_col2.format("g", 'Generate graphs for current history') - self.view_data['show_hide_left_sidebar'] = msg_col.format("2", 'Show/hide left sidebar') - self.view_data['reset_history'] = msg_col2.format("r", 'Reset history') - self.view_data['enable_disable_process_stats'] = msg_col.format("z", 'Enable/disable processes stats') - self.view_data['quit'] = msg_col2.format("q", 'Quit (Esc and Ctrl-C also work)') - self.view_data['enable_disable_top_extends_stats'] = msg_col.format("e", 'Enable/disable top extended stats') - self.view_data['enable_disable_short_processname'] = msg_col.format("/", 'Enable/disable short processes name') - self.view_data['enable_disable_docker'] = msg_col2.format("D", 'Enable/disable Docker stats') - self.view_data['enable_disable_quick_look'] = msg_col.format("3", 'Enable/disable quick look plugin') - self.view_data['edit_pattern_filter'] = '{0}: {1}'.format("ENTER", 'Edit the process filter pattern') + 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%') + self.view_data['show_hide_alert'] = msg_col2.format('l', 'Show/hide alert logs') + self.view_data['sort_mem'] = msg_col.format('m', 'Sort processes by MEM%') + self.view_data['sort_user'] = msg_col.format('u', 'Sort processes by USER') + self.view_data['delete_warning_alerts'] = msg_col2.format('w', 'Delete warning alerts') + self.view_data['sort_proc'] = msg_col.format('p', 'Sort processes by name') + self.view_data['delete_warning_critical_alerts'] = msg_col2.format('x', 'Delete warning and critical alerts') + self.view_data['sort_io'] = msg_col.format('i', 'Sort processes by I/O rate') + self.view_data['percpu'] = msg_col2.format('1', 'Global CPU or per-CPU stats') + 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['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') + self.view_data['show_hide_filesytem_freespace'] = msg_col2.format('F', 'Show filesystem free space') + self.view_data['show_hide_sensors'] = msg_col.format('s', 'Show/hide sensors stats') + self.view_data['generate_graphs'] = msg_col2.format('g', 'Generate graphs for current history') + self.view_data['show_hide_left_sidebar'] = msg_col.format('2', 'Show/hide left sidebar') + self.view_data['reset_history'] = msg_col2.format('r', 'Reset history') + self.view_data['enable_disable_process_stats'] = msg_col.format('z', 'Enable/disable processes stats') + self.view_data['quit'] = msg_col2.format('q', 'Quit (Esc and Ctrl-C also work)') + self.view_data['enable_disable_top_extends_stats'] = msg_col.format('e', 'Enable/disable top extended stats') + self.view_data['enable_disable_short_processname'] = msg_col.format('/', 'Enable/disable short processes name') + self.view_data['enable_disable_docker'] = msg_col2.format('D', 'Enable/disable Docker stats') + self.view_data['enable_disable_quick_look'] = msg_col.format('3', 'Enable/disable quick look plugin') + self.view_data['edit_pattern_filter'] = 'ENTER: Edit the process filter pattern' def get_view_data(self, args=None): return self.view_data diff --git a/glances/plugins/glances_mem.py b/glances/plugins/glances_mem.py index 106dfabb..6b4ace8c 100644 --- a/glances/plugins/glances_mem.py +++ b/glances/plugins/glances_mem.py @@ -19,10 +19,10 @@ """Virtual memory plugin.""" -import psutil - from glances.plugins.glances_plugin import GlancesPlugin +import psutil + # SNMP OID # Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0 # Total RAM used: .1.3.6.1.4.1.2021.4.6.0 @@ -123,7 +123,7 @@ class Plugin(GlancesPlugin): self.reset() else: for fs in fs_stat: - # The Physical Memory (Windows) or Real Memory (VmWare) + # The Physical Memory (Windows) or Real Memory (VMware) # gives statistics on RAM usage and availability. if fs in ('Physical Memory', 'Real Memory'): self.stats['total'] = int(fs_stat[fs]['size']) * int(fs_stat[fs]['alloc_unit']) diff --git a/glances/plugins/glances_memswap.py b/glances/plugins/glances_memswap.py index 00a3322b..5164e592 100644 --- a/glances/plugins/glances_memswap.py +++ b/glances/plugins/glances_memswap.py @@ -19,10 +19,10 @@ """Swap memory plugin.""" -import psutil - from glances.plugins.glances_plugin import GlancesPlugin +import psutil + # SNMP OID # Total Swap Size: .1.3.6.1.4.1.2021.4.3.0 # Available Swap Space: .1.3.6.1.4.1.2021.4.4.0 @@ -95,9 +95,10 @@ class Plugin(GlancesPlugin): self.reset() else: for fs in fs_stat: - # The virtual memory concept is used by the operating system to extend (virtually) the physical - # memory and thus to run more programs by swapping - # unused memory zone (page) to a disk file. + # The virtual memory concept is used by the operating + # system to extend (virtually) the physical memory and + # thus to run more programs by swapping unused memory + # zone (page) to a disk file. if fs == 'Virtual Memory': self.stats['total'] = int( fs_stat[fs]['size']) * int(fs_stat[fs]['alloc_unit']) diff --git a/glances/plugins/glances_monitor.py b/glances/plugins/glances_monitor.py index caacd03d..5c332787 100644 --- a/glances/plugins/glances_monitor.py +++ b/glances/plugins/glances_monitor.py @@ -20,7 +20,6 @@ """Monitor plugin.""" # Import Glances lib -from glances.core.glances_logging import logger from glances.core.glances_monitor_list import MonitorList as glancesMonitorList from glances.plugins.glances_plugin import GlancesPlugin diff --git a/glances/plugins/glances_network.py b/glances/plugins/glances_network.py index 29a73e5e..c33f0022 100644 --- a/glances/plugins/glances_network.py +++ b/glances/plugins/glances_network.py @@ -22,11 +22,11 @@ import base64 import operator -import psutil - from glances.core.glances_timer import getTimeSinceLastUpdate from glances.plugins.glances_plugin import GlancesPlugin +import psutil + # SNMP OID # http://www.net-snmp.org/docs/mibs/interfaces.html # Dict key = interface_name @@ -269,20 +269,20 @@ class Plugin(GlancesPlugin): if args.network_cumul: rx = self.auto_unit(int(i['cumulative_rx'])) tx = self.auto_unit(int(i['cumulative_tx'])) - sx = self.auto_unit(int(i['cumulative_tx']) - + int(i['cumulative_tx'])) + sx = self.auto_unit(int(i['cumulative_tx']) + + int(i['cumulative_tx'])) else: rx = self.auto_unit(int(i['rx'] // i['time_since_update'])) tx = self.auto_unit(int(i['tx'] // i['time_since_update'])) - sx = self.auto_unit(int(i['rx'] // i['time_since_update']) - + int(i['tx'] // i['time_since_update'])) + sx = self.auto_unit(int(i['rx'] // i['time_since_update']) + + int(i['tx'] // i['time_since_update'])) else: # Bits per second (for real network administrator | Default) if args.network_cumul: rx = self.auto_unit(int(i['cumulative_rx'] * 8)) + "b" tx = self.auto_unit(int(i['cumulative_tx'] * 8)) + "b" - sx = self.auto_unit(int(i['cumulative_rx'] * 8) - + int(i['cumulative_tx'] * 8)) + "b" + sx = self.auto_unit(int(i['cumulative_rx'] * 8) + + int(i['cumulative_tx'] * 8)) + "b" else: rx = self.auto_unit(int(i['rx'] // i['time_since_update'] * 8)) + "b" tx = self.auto_unit(int(i['tx'] // i['time_since_update'] * 8)) + "b" diff --git a/glances/plugins/glances_percpu.py b/glances/plugins/glances_percpu.py index 389c8033..8ec38a2c 100644 --- a/glances/plugins/glances_percpu.py +++ b/glances/plugins/glances_percpu.py @@ -19,10 +19,10 @@ """Per-CPU plugin.""" -import psutil - from glances.plugins.glances_plugin import GlancesPlugin +import psutil + class Plugin(GlancesPlugin): diff --git a/glances/plugins/glances_plugin.py b/glances/plugins/glances_plugin.py index 8c95038f..7eb1de8e 100644 --- a/glances/plugins/glances_plugin.py +++ b/glances/plugins/glances_plugin.py @@ -29,10 +29,10 @@ from datetime import datetime from operator import itemgetter # Import Glances lib +from glances.core.glances_actions import GlancesActions from glances.core.glances_globals import is_py3 from glances.core.glances_logging import logger from glances.core.glances_logs import glances_logs -from glances.core.glances_actions import GlancesActions class GlancesPlugin(object): diff --git a/glances/plugins/glances_psutilversion.py b/glances/plugins/glances_psutilversion.py index bfdbe878..021a0bc5 100644 --- a/glances/plugins/glances_psutilversion.py +++ b/glances/plugins/glances_psutilversion.py @@ -17,10 +17,10 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . -from psutil import __version__ as __psutil_version - from glances.plugins.glances_plugin import GlancesPlugin +from psutil import __version__ as __psutil_version + class Plugin(GlancesPlugin): diff --git a/glances/plugins/glances_quicklook.py b/glances/plugins/glances_quicklook.py index 1b5f206f..b6711376 100644 --- a/glances/plugins/glances_quicklook.py +++ b/glances/plugins/glances_quicklook.py @@ -19,12 +19,11 @@ """Quicklook plugin.""" -import psutil - -from glances.plugins.glances_plugin import GlancesPlugin from glances.core.glances_cpu_percent import cpu_percent from glances.outputs.glances_bars import Bar -#from glances.core.glances_logging import logger +from glances.plugins.glances_plugin import GlancesPlugin + +import psutil class Plugin(GlancesPlugin): diff --git a/glances/plugins/glances_uptime.py b/glances/plugins/glances_uptime.py index bb67e7cf..17d7871c 100644 --- a/glances/plugins/glances_uptime.py +++ b/glances/plugins/glances_uptime.py @@ -22,12 +22,12 @@ # Import system libs from datetime import datetime, timedelta -# Import psutil -import psutil - # Import Glances libs from glances.plugins.glances_plugin import GlancesPlugin +# Import psutil +import psutil + # SNMP OID snmp_oid = {'_uptime': '1.3.6.1.2.1.1.3.0'} -- GitLab