diff --git a/glances/core/glances_client.py b/glances/core/glances_client.py index e207dc5d..5e3f2c71 100644 --- a/glances/core/glances_client.py +++ b/glances/core/glances_client.py @@ -32,10 +32,10 @@ except ImportError: # Python 2 # Import Glances libs from glances.core.glances_globals import version from glances.core.glances_stats import GlancesStatsClient -from glances.outputs.glances_curses import glancesCurses +from glances.outputs.glances_curses import GlancesCurses -class GlancesClient(): +class GlancesClient(object): """ This class creates and manages the TCP client """ @@ -126,7 +126,7 @@ class GlancesClient(): self.stats.load_limits(self.config) # Init screen - self.screen = glancesCurses(args=self.args) + self.screen = GlancesCurses(args=self.args) # Return result return ret @@ -201,4 +201,3 @@ class GlancesClient(): End of the client session """ self.screen.end() - diff --git a/glances/core/glances_globals.py b/glances/core/glances_globals.py index 7de11090..5b46cee4 100644 --- a/glances/core/glances_globals.py +++ b/glances/core/glances_globals.py @@ -60,9 +60,9 @@ else: # ============================================ # glances_processes for processcount and processlist plugins -from glances.core.glances_processes import glancesProcesses -glances_processes = glancesProcesses() +from glances.core.glances_processes import GlancesProcesses +glances_processes = GlancesProcesses() # The global instance for the logs -from glances.core.glances_logs import glancesLogs -glances_logs = glancesLogs() +from glances.core.glances_logs import GlancesLogs +glances_logs = GlancesLogs() diff --git a/glances/core/glances_logs.py b/glances/core/glances_logs.py index 37e3143e..99f97cc0 100644 --- a/glances/core/glances_logs.py +++ b/glances/core/glances_logs.py @@ -25,7 +25,7 @@ from datetime import datetime from glances.core.glances_globals import glances_processes -class glancesLogs: +class GlancesLogs(object): """ Manage logs inside the Glances software Logs is a list of list (stored in the self.logs_list var) diff --git a/glances/core/glances_main.py b/glances/core/glances_main.py index d3d2692b..50c49482 100644 --- a/glances/core/glances_main.py +++ b/glances/core/glances_main.py @@ -175,9 +175,9 @@ class GlancesMain(object): """ Hash a plain password and return the hashed one """ - from glances.core.glances_password import glancesPassword + from glances.core.glances_password import GlancesPassword - password = glancesPassword() + password = GlancesPassword() return password.hash_password(plain_password) @@ -187,9 +187,9 @@ class GlancesMain(object): - with confirmation if confirm = True - plain (clear password) if clear = True """ - from glances.core.glances_password import glancesPassword + from glances.core.glances_password import GlancesPassword - password = glancesPassword() + password = GlancesPassword() return password.get_password(description, confirm, clear) diff --git a/glances/core/glances_monitor_list.py b/glances/core/glances_monitor_list.py index 4de6fcf0..33ce74c2 100644 --- a/glances/core/glances_monitor_list.py +++ b/glances/core/glances_monitor_list.py @@ -25,7 +25,7 @@ import subprocess from glances.core.glances_globals import glances_processes -class monitorList: +class MonitorList(object): """ This class describes the optionnal monitored processes list A list of 'important' processes to monitor. @@ -52,11 +52,11 @@ class monitorList: if self.config is not None and self.config.has_section('monitor'): # Process monitoring list - self.__setMonitorList('monitor', 'list') + self.__set_monitor_list('monitor', 'list') else: self.__monitor_list = [] - def __setMonitorList(self, section, key): + def __set_monitor_list(self, section, key): """ Init the monitored processes list The list is defined in the Glances configuration file diff --git a/glances/core/glances_password.py b/glances/core/glances_password.py index 04bd7385..96b1bd6b 100644 --- a/glances/core/glances_password.py +++ b/glances/core/glances_password.py @@ -40,7 +40,7 @@ except NameError: pass -class glancesPassword: +class GlancesPassword(object): """ Manage password """ diff --git a/glances/core/glances_processes.py b/glances/core/glances_processes.py index 48640b56..a36044d9 100644 --- a/glances/core/glances_processes.py +++ b/glances/core/glances_processes.py @@ -17,14 +17,13 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see . -import psutil - -# Import Glances lib from glances.core.glances_globals import is_bsd, is_mac, is_windows from glances.core.glances_timer import Timer, getTimeSinceLastUpdate +import psutil -class glancesProcesses: + +class GlancesProcesses(object): """ Get processed stats using the PsUtil lib """ diff --git a/glances/core/glances_server.py b/glances/core/glances_server.py index 0325894a..56244e00 100644 --- a/glances/core/glances_server.py +++ b/glances/core/glances_server.py @@ -65,22 +65,22 @@ class GlancesXMLRPCHandler(SimpleXMLRPCRequestHandler): assert basic == 'Basic', 'Only basic authentication supported' # Encoded portion of the header is a string # Need to convert to bytestring - encodedByteString = encoded.encode() + encoded_byte_string = encoded.encode() # Decode Base64 byte String to a decoded Byte String - decodedBytes = b64decode(encodedByteString) + decoded_bytes = b64decode(encoded_byte_string) # Convert from byte string to a regular String - decodedString = decodedBytes.decode() + decoded_string = decoded_bytes.decode() # Get the username and password from the string - (username, _, password) = decodedString.partition(':') + (username, _, password) = decoded_string.partition(':') # Check that username and password match internal global dictionary return self.check_user(username, password) def check_user(self, username, password): # Check username and password in the dictionnary if username in self.server.user_dict: - from glances.core.glances_password import glancesPassword + from glances.core.glances_password import GlancesPassword - pwd = glancesPassword() + pwd = GlancesPassword() return pwd.check_password(self.server.user_dict[username], password) else: @@ -119,7 +119,7 @@ class GlancesXMLRPCServer(SimpleXMLRPCServer): requestHandler) -class GlancesInstance(): +class GlancesInstance(object): """ All the methods of this class are published as XML RPC methods """ @@ -189,7 +189,7 @@ class GlancesInstance(): raise AttributeError(item) -class GlancesServer(): +class GlancesServer(object): """ This class creates and manages the TCP server """ diff --git a/glances/core/glances_standalone.py b/glances/core/glances_standalone.py index 2c89d537..c6edf589 100644 --- a/glances/core/glances_standalone.py +++ b/glances/core/glances_standalone.py @@ -19,10 +19,10 @@ # Import Glances libs from glances.core.glances_stats import GlancesStats -from glances.outputs.glances_curses import glancesCurses +from glances.outputs.glances_curses import GlancesCurses -class GlancesStandalone(): +class GlancesStandalone(object): """ This class creates and manages the Glances standalone session """ @@ -37,15 +37,15 @@ class GlancesStandalone(): # Init CSV output if args.output_csv is not None: - from glances.outputs.glances_csv import glancesCSV + from glances.outputs.glances_csv import GlancesCSV - self.csvoutput = glancesCSV(args=args) + self.csvoutput = GlancesCSV(args=args) self.csv_tag = True else: self.csv_tag = False # Init screen - self.screen = glancesCurses(args=args) + self.screen = GlancesCurses(args=args) def serve_forever(self): """ diff --git a/glances/core/glances_timer.py b/glances/core/glances_timer.py index ce9ce4ef..7c5710ab 100644 --- a/glances/core/glances_timer.py +++ b/glances/core/glances_timer.py @@ -36,7 +36,7 @@ def getTimeSinceLastUpdate(IOType): return time_since_update -class Timer: +class Timer(object): """ The timer class A simple chrono @@ -57,4 +57,3 @@ class Timer: def finished(self): return time() > self.target - diff --git a/glances/core/glances_webserver.py b/glances/core/glances_webserver.py index 6c134feb..c8249710 100644 --- a/glances/core/glances_webserver.py +++ b/glances/core/glances_webserver.py @@ -22,10 +22,10 @@ Glances Web Interface (Bottle based) # Import Glances libs from glances.core.glances_stats import GlancesStats -from glances.outputs.glances_bottle import glancesBottle +from glances.outputs.glances_bottle import GlancesBottle -class GlancesWebServer(): +class GlancesWebServer(object): """ This class creates and manages the Glances Web Server session """ @@ -39,7 +39,7 @@ class GlancesWebServer(): self.stats.update() # Init the Bottle Web server - self.web = glancesBottle(args=args) + self.web = GlancesBottle(args=args) def serve_forever(self): """ diff --git a/glances/outputs/glances_bottle.py b/glances/outputs/glances_bottle.py index fe5ea208..08673a73 100644 --- a/glances/outputs/glances_bottle.py +++ b/glances/outputs/glances_bottle.py @@ -27,7 +27,7 @@ except ImportError: sys.exit(1) -class glancesBottle: +class GlancesBottle(object): """ This class manage the Bottle Web Server """ @@ -186,7 +186,7 @@ class glancesBottle: if m['msg'].split(' ', 1)[0] != '': tpl += ' %s' % \ (self.__style_list[m['decoration']], - m['msg'].split(' ', 1)[0].replace(' ', ' ')[:20]) + m['msg'].split(' ', 1)[0].replace(' ', ' ')[:20]) elif m['optional']: # Manage optional stats (responsive design) tpl += '%s' % \ diff --git a/glances/outputs/glances_colorconsole.py b/glances/outputs/glances_colorconsole.py index 20d9b1ae..f61f66a2 100644 --- a/glances/outputs/glances_colorconsole.py +++ b/glances/outputs/glances_colorconsole.py @@ -59,7 +59,7 @@ class ListenGetch(threading.Thread): return default -class Screen(): +class Screen(object): COLOR_DEFAULT_WIN = '0F' # 07'#'0F' COLOR_BK_DEFAULT = colorconsole.terminal.colors["BLACK"] @@ -116,7 +116,7 @@ class Screen(): return None -class WCurseLight(): +class WCurseLight(object): COLOR_WHITE = colorconsole.terminal.colors["WHITE"] COLOR_RED = colorconsole.terminal.colors["RED"] diff --git a/glances/outputs/glances_csv.py b/glances/outputs/glances_csv.py index ae17e267..4c129344 100644 --- a/glances/outputs/glances_csv.py +++ b/glances/outputs/glances_csv.py @@ -28,7 +28,7 @@ from glances.core.glances_globals import is_py3 csv_stats_list = ['cpu', 'load', 'mem', 'memswap'] -class glancesCSV: +class GlancesCSV(object): """ This class manages the CSV output """ diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index a07f32b3..147433d0 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -37,7 +37,7 @@ else: curses = WCurseLight() -class glancesCurses: +class GlancesCurses(object): """ This class manage the curses display (and key pressed) """ @@ -160,7 +160,7 @@ class glancesCurses: self.term_window.nodelay(1) self.pressedkey = -1 - def __getkey(self, window): + def __get_key(self, window): """ A getKey function to catch ESC key AND Numlock key (issue #163) """ @@ -174,10 +174,10 @@ class glancesCurses: else: return keycode[0] - def __catchKey(self): + def __catch_key(self): # Get key - #~ self.pressedkey = self.term_window.getch() - self.pressedkey = self.__getkey(self.term_window) + # ~ self.pressedkey = self.term_window.getch() + self.pressedkey = self.__get_key(self.term_window) # Actions... if self.pressedkey == ord('\x1b') or self.pressedkey == ord('q'): @@ -456,7 +456,7 @@ class glancesCurses: countdown = Timer(self.__refresh_time) while (not countdown.finished()): # Getkey - if self.__catchKey() > -1: + if self.__catch_key() > -1: # flush display self.flush(stats, cs_status=cs_status) # Wait 100ms... diff --git a/glances/plugins/glances_batpercent.py b/glances/plugins/glances_batpercent.py index c961aa07..335e4dd8 100644 --- a/glances/plugins/glances_batpercent.py +++ b/glances/plugins/glances_batpercent.py @@ -41,7 +41,7 @@ class Plugin(GlancesPlugin): GlancesPlugin.__init__(self, args=args) # Init the sensor class - self.glancesgrabbat = glancesGrabBat() + self.glancesgrabbat = GlancesGrabBat() # We do not want to display the stat in a dedicated area # The HDD temp is displayed within the sensors plugin @@ -78,7 +78,7 @@ class Plugin(GlancesPlugin): return self.stats -class glancesGrabBat: +class GlancesGrabBat(object): """ Get batteries stats using the Batinfo library """ diff --git a/glances/plugins/glances_core.py b/glances/plugins/glances_core.py index dd147eab..d060b2b4 100644 --- a/glances/plugins/glances_core.py +++ b/glances/plugins/glances_core.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 . -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 dbf541b6..2d229c84 100644 --- a/glances/plugins/glances_cpu.py +++ b/glances/plugins/glances_cpu.py @@ -20,10 +20,10 @@ Glances CPU plugin """ -import psutil - 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 # percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0 diff --git a/glances/plugins/glances_diskio.py b/glances/plugins/glances_diskio.py index f0c572f6..87f4041f 100644 --- a/glances/plugins/glances_diskio.py +++ b/glances/plugins/glances_diskio.py @@ -20,12 +20,12 @@ Glances DiskIO plugin """ -import psutil - # Import Glances libs from glances.core.glances_timer import getTimeSinceLastUpdate from glances.plugins.glances_plugin import GlancesPlugin +import psutil + class Plugin(GlancesPlugin): """ diff --git a/glances/plugins/glances_fs.py b/glances/plugins/glances_fs.py index db41cbcd..e3c2b1e2 100644 --- a/glances/plugins/glances_fs.py +++ b/glances/plugins/glances_fs.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 . -import psutil - from glances.plugins.glances_plugin import GlancesPlugin +import psutil + # SNMP OID # The snmpd.conf needs to be edited. # Add the following to enable it on all disk diff --git a/glances/plugins/glances_hddtemp.py b/glances/plugins/glances_hddtemp.py index 89423b29..3deeb85a 100644 --- a/glances/plugins/glances_hddtemp.py +++ b/glances/plugins/glances_hddtemp.py @@ -35,7 +35,7 @@ class Plugin(GlancesPlugin): GlancesPlugin.__init__(self, args=args) # Init the sensor class - self.glancesgrabhddtemp = glancesGrabHDDTemp() + self.glancesgrabhddtemp = GlancesGrabHDDTemp() # We do not want to display the stat in a dedicated area # The HDD temp is displayed within the sensors plugin @@ -70,7 +70,7 @@ class Plugin(GlancesPlugin): return self.stats -class glancesGrabHDDTemp: +class GlancesGrabHDDTemp(object): """ Get hddtemp stats using a socket connection """ diff --git a/glances/plugins/glances_mem.py b/glances/plugins/glances_mem.py index b11bdb3a..d102854a 100644 --- a/glances/plugins/glances_mem.py +++ b/glances/plugins/glances_mem.py @@ -20,10 +20,10 @@ Glances 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 diff --git a/glances/plugins/glances_memswap.py b/glances/plugins/glances_memswap.py index 57307ec2..98591350 100644 --- a/glances/plugins/glances_memswap.py +++ b/glances/plugins/glances_memswap.py @@ -20,10 +20,10 @@ Glances 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 diff --git a/glances/plugins/glances_monitor.py b/glances/plugins/glances_monitor.py index 3cefe211..a1d16b3b 100644 --- a/glances/plugins/glances_monitor.py +++ b/glances/plugins/glances_monitor.py @@ -18,7 +18,7 @@ # along with this program. If not, see . # Import Glances lib -from glances.core.glances_monitor_list import monitorList as glancesMonitorList +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 d9bd26df..68176c55 100644 --- a/glances/plugins/glances_network.py +++ b/glances/plugins/glances_network.py @@ -20,13 +20,11 @@ Glances Network interface plugin """ -# Import system libs -import psutil - -# Import Glances lib 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 @@ -169,7 +167,7 @@ class Plugin(GlancesPlugin): Return the dict to displayoid in the curse interface """ - #!!! TODO: Add alert on network interface bitrate + # !!! TODO: Add alert on network interface bitrate # Init the return message ret = [] diff --git a/glances/plugins/glances_percpu.py b/glances/plugins/glances_percpu.py index 0bdf04c6..88942541 100644 --- a/glances/plugins/glances_percpu.py +++ b/glances/plugins/glances_percpu.py @@ -20,12 +20,12 @@ CPU stats (per cpu) """ -# Check for psutil already done in the glances_core script -import psutil - # Import Glances libs from glances.plugins.glances_plugin import GlancesPlugin +# Check for psutil already done in the glances_core script +import psutil + class Plugin(GlancesPlugin): """ diff --git a/glances/plugins/glances_plugin.py b/glances/plugins/glances_plugin.py index 95408ba9..e157c514 100644 --- a/glances/plugins/glances_plugin.py +++ b/glances/plugins/glances_plugin.py @@ -256,7 +256,7 @@ class GlancesPlugin(object): def get_stats_display(self, args=None): # Return a dict with all the information needed to display the stat # key | description - #---------------------------- + # ---------------------------- # display | Display the stat (True or False) # msgdict | Message to display (list of dict [{ 'msg': msg, 'decoration': decoration } ... ]) # column | column number diff --git a/glances/plugins/glances_psutilversion.py b/glances/plugins/glances_psutilversion.py index 1999f9f3..21199913 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_sensors.py b/glances/plugins/glances_sensors.py index 9b18e8c6..8e7070fc 100644 --- a/glances/plugins/glances_sensors.py +++ b/glances/plugins/glances_sensors.py @@ -44,7 +44,7 @@ class Plugin(GlancesPlugin): GlancesPlugin.__init__(self, args=args) # Init the sensor class - self.glancesgrabsensors = glancesGrabSensors() + self.glancesgrabsensors = GlancesGrabSensors() # Instance for the HDDTemp Plugin in order to display the hard disks temperatures self.hddtemp_plugin = HddTempPlugin() @@ -143,7 +143,7 @@ class Plugin(GlancesPlugin): return ret -class glancesGrabSensors: +class GlancesGrabSensors(object): """ Get sensors stats using the PySensors library """ diff --git a/glances/plugins/glances_system.py b/glances/plugins/glances_system.py index 922b43ae..29fdaeab 100644 --- a/glances/plugins/glances_system.py +++ b/glances/plugins/glances_system.py @@ -31,6 +31,7 @@ from glances.plugins.glances_plugin import GlancesPlugin snmp_oid = {'hostname': '1.3.6.1.2.1.1.5.0', 'os_name': '1.3.6.1.2.1.1.1.0'} + class Plugin(GlancesPlugin): """ Glances' Host/System Plugin diff --git a/glances/plugins/glances_uptime.py b/glances/plugins/glances_uptime.py index e482d230..900fe1c2 100644 --- a/glances/plugins/glances_uptime.py +++ b/glances/plugins/glances_uptime.py @@ -20,15 +20,16 @@ # Import system libs from datetime import datetime, timedelta -# Check for psutil already done in the glances_core script -import psutil - # Import Glances libs from glances.plugins.glances_plugin import GlancesPlugin +# Check for psutil already done in the glances_core script +import psutil + # SNMP OID snmp_oid = {'_uptime': '1.3.6.1.2.1.1.3.0'} + class Plugin(GlancesPlugin): """ Glances' Uptime Plugin