diff options
author | nicolargo <nicolashennion@gmail.com> | 2024-05-18 10:37:57 +0200 |
---|---|---|
committer | nicolargo <nicolashennion@gmail.com> | 2024-05-18 10:37:57 +0200 |
commit | 74f9606e654b0670f9d9a4ec53445ed85609254d (patch) | |
tree | 881a0392b855b3ffabed5050e23eec961521aea0 /glances | |
parent | 5262524db37b7173aa866007d8f4a46d1832d5c0 (diff) | |
parent | a99bf33b4b982c057fb0b4ce47b59df41c7a3ca7 (diff) |
Merge Ruff formating and solve some conflicts #2779
Diffstat (limited to 'glances')
113 files changed, 1166 insertions, 1429 deletions
diff --git a/glances/__init__.py b/glances/__init__.py index a8d3ce28..e8ff04cb 100644 --- a/glances/__init__.py +++ b/glances/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # This file is part of Glances. # @@ -11,11 +10,11 @@ """Init the Glances software.""" # Import system libs -import tracemalloc import locale import platform import signal import sys +import tracemalloc # Global name # Version should start and end with a numerical char @@ -44,11 +43,6 @@ try: except locale.Error: print("Warning: Unable to set locale. Expect encoding problems.") -# Check Python version -if sys.version_info < (3, 4): - print('Glances requires at least Python 3.4 to run.') - sys.exit(1) - # Check psutil version psutil_min_version = (5, 3, 0) psutil_version_info = tuple([int(num) for num in psutil_version.split('.')]) @@ -56,11 +50,12 @@ if psutil_version_info < psutil_min_version: print('psutil 5.3.0 or higher is needed. Glances cannot start.') sys.exit(1) + # Trac malloc is only available on Python 3.4 or higher def __signal_handler(signal, frame): - logger.debug("Signal {} catched".format(signal)) + logger.debug(f"Signal {signal} catched") end() @@ -103,20 +98,16 @@ def start(config, args): from glances.webserver import GlancesWebServer as GlancesMode # Init the mode - logger.info("Start {} mode".format(GlancesMode.__name__)) + logger.info(f"Start {GlancesMode.__name__} mode") mode = GlancesMode(config=config, args=args) # Start the main loop - logger.debug("Glances started in {} seconds".format(start_duration.get())) + logger.debug(f"Glances started in {start_duration.get()} seconds") if args.stop_after: - logger.info('Glances will be stopped in ~{} seconds'.format(args.stop_after * args.time)) + logger.info(f'Glances will be stopped in ~{args.stop_after * args.time} seconds') if args.memory_leak: - print( - 'Memory leak detection, please wait ~{} seconds...'.format( - args.stop_after * args.time * args.memory_leak * 2 - ) - ) + print(f'Memory leak detection, please wait ~{args.stop_after * args.time * args.memory_leak * 2} seconds...') # First run without dump to fill the memory mode.serve_n(args.stop_after) # Then start the memory-leak loop @@ -133,7 +124,7 @@ def start(config, args): snapshot_end = tracemalloc.take_snapshot() snapshot_diff = snapshot_end.compare_to(snapshot_begin, 'filename') memory_leak = sum([s.size_diff for s in snapshot_diff]) - print("Memory consumption: {0:.1f}KB (see log for details)".format(memory_leak / 1000)) + print(f"Memory consumption: {memory_leak / 1000:.1f}KB (see log for details)") logger.info("Memory consumption (top 5):") for stat in snapshot_diff[:5]: logger.info(stat) @@ -165,12 +156,10 @@ def main(): signal.signal(sig, __signal_handler) # Log Glances and psutil version - logger.info('Start Glances {}'.format(__version__)) - logger.info( - '{} {} ({}) and psutil {} detected'.format( - platform.python_implementation(), platform.python_version(), sys.executable, psutil_version - ) - ) + logger.info(f'Start Glances {__version__}') + python_impl = platform.python_implementation() + python_ver = platform.python_version() + logger.info(f'{python_impl} {python_ver} ({sys.executable}) and psutil {psutil_version} detected') # Share global var global core diff --git a/glances/__main__.py b/glances/__main__.py index 0da0b639..58cca551 100644 --- a/glances/__main__.py +++ b/glances/__main__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Glances - An eye on your system # diff --git a/glances/actions.py b/glances/actions.py index f61475cb..5ea247bb 100644 --- a/glances/actions.py +++ b/glances/actions.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # This file is part of Glances. # @@ -10,8 +9,8 @@ """Manage on alert actions.""" from glances.logger import logger -from glances.timer import Timer from glances.secure import secure_popen +from glances.timer import Timer try: import chevron @@ -22,7 +21,7 @@ else: chevron_tag = True -class GlancesActions(object): +class GlancesActions: """This class manage action if an alert is reached.""" def __init__(self, args=None): @@ -80,13 +79,13 @@ class GlancesActions(object): |