chg: ruff - isort fixes

This commit is contained in:
Bharath Vignesh J K 2024-05-17 02:23:53 +05:30
parent 9890749d81
commit d392caf6f6
97 changed files with 286 additions and 274 deletions

View File

@ -12,8 +12,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import sys
from datetime import datetime
# If extensions (or modules to document with autodoc) are in another directory,
@ -27,7 +27,6 @@ sys.path.insert(0, os.path.abspath('..'))
# WARNING: Do not move this import before the sys.path.insert() call.
from glances import __version__
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.

View File

@ -11,11 +11,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

View File

@ -10,8 +10,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

View File

@ -23,8 +23,8 @@ If the *one_line* var is true then the AMP will be displayed in one line.
"""
from glances.globals import u
from glances.timer import Timer
from glances.logger import logger
from glances.timer import Timer
class GlancesAmp(object):

View File

@ -25,11 +25,11 @@ one_line=false
command=foo status
"""
from subprocess import check_output, STDOUT, CalledProcessError
from subprocess import STDOUT, CalledProcessError, check_output
from glances.globals import u, to_ascii
from glances.logger import logger
from glances.amps.amp import GlancesAmp
from glances.globals import to_ascii, u
from glances.logger import logger
class Amp(GlancesAmp):

View File

@ -46,8 +46,8 @@ status_url=http://localhost/nginx_status
import requests
from glances.logger import logger
from glances.amps.amp import GlancesAmp
from glances.logger import logger
class Amp(GlancesAmp):

View File

@ -35,11 +35,11 @@ one_line=true
systemctl_cmd=/usr/bin/systemctl --plain
"""
from subprocess import check_output, CalledProcessError
from subprocess import CalledProcessError, check_output
from glances.logger import logger
from glances.globals import iteritems, to_ascii
from glances.amps.amp import GlancesAmp
from glances.globals import iteritems, to_ascii
from glances.logger import logger
class Amp(GlancesAmp):

View File

@ -34,11 +34,11 @@ one_line=true
service_cmd=/usr/bin/service --status-all
"""
from subprocess import check_output, STDOUT
from subprocess import STDOUT, check_output
from glances.logger import logger
from glances.globals import iteritems
from glances.amps.amp import GlancesAmp
from glances.globals import iteritems
from glances.logger import logger
class Amp(GlancesAmp):

View File

@ -13,7 +13,7 @@ import os
import re
import threading
from glances.globals import listkeys, iteritems, amps_path
from glances.globals import amps_path, iteritems, listkeys
from glances.logger import logger
from glances.processes import glances_processes

View File

@ -16,7 +16,8 @@ from glances.globals import BSD
from glances.logger import logger
try:
from zeroconf import __version__ as __zeroconf_version, ServiceBrowser, ServiceInfo, Zeroconf
from zeroconf import ServiceBrowser, ServiceInfo, Zeroconf
from zeroconf import __version__ as __zeroconf_version
zeroconf_tag = True
except ImportError:

View File

@ -9,16 +9,17 @@
"""Manage the Glances client."""
import ujson
import socket
import sys
import time
import ujson
from glances import __version__
from glances.globals import Fault, ProtocolError, ServerProxy, Transport
from glances.logger import logger
from glances.stats_client import GlancesStatsClient
from glances.outputs.glances_curses import GlancesCursesClient
from glances.stats_client import GlancesStatsClient
from glances.timer import Counter

View File

@ -9,17 +9,18 @@
"""Manage the Glances client browser (list of Glances server)."""
import ujson
import socket
import threading
from glances.globals import Fault, ProtocolError, ServerProxy
import ujson
from glances.autodiscover import GlancesAutoDiscoverServer
from glances.client import GlancesClient, GlancesClientTransport
from glances.logger import logger, LOG_FILENAME
from glances.globals import Fault, ProtocolError, ServerProxy
from glances.logger import LOG_FILENAME, logger
from glances.outputs.glances_curses_browser import GlancesCursesBrowser
from glances.password_list import GlancesPasswordList as GlancesPassword
from glances.static_list import GlancesStaticServer
from glances.autodiscover import GlancesAutoDiscoverServer
from glances.outputs.glances_curses_browser import GlancesCursesBrowser
class GlancesClientBrowser(object):

View File

@ -9,13 +9,13 @@
"""Manage the configuration file."""
import os
import sys
import multiprocessing
from io import open
import os
import re
import sys
from io import open
from glances.globals import ConfigParser, NoOptionError, NoSectionError, system_exec, BSD, LINUX, MACOS, SUNOS, WINDOWS
from glances.globals import BSD, LINUX, MACOS, SUNOS, WINDOWS, ConfigParser, NoOptionError, NoSectionError, system_exec
from glances.logger import logger

View File

@ -9,11 +9,11 @@
"""CPU percent stats shared between CPU and Quicklook plugins."""
import psutil
from glances.logger import logger
from glances.timer import Timer
import psutil
class CpuPercent(object):
"""Get and store the CPU percent."""

View File

@ -10,12 +10,12 @@
"""Manage Glances events list (previously Glances logs in Glances < 3.1)."""
import time
from datetime import datetime
from dataclasses import asdict
from datetime import datetime
from glances.event import GlancesEvent
from glances.processes import glances_processes
from glances.thresholds import glances_thresholds
from glances.event import GlancesEvent
# Static decision tree for the global alert message
# - msg: Message to be displayed (result of the decision tree)

View File

@ -13,10 +13,9 @@ I am your father...
...for all Glances exports IF.
"""
from glances.globals import json_dumps
from glances.globals import NoOptionError, NoSectionError, iteritems, iterkeys
from glances.timer import Counter
from glances.globals import NoOptionError, NoSectionError, iteritems, iterkeys, json_dumps
from glances.logger import logger
from glances.timer import Counter
class GlancesExport(object):

View File

@ -13,13 +13,13 @@ import sys
from datetime import datetime
from numbers import Number
from glances.logger import logger
from glances.exports.export import GlancesExport
from cassandra import InvalidRequest
from cassandra.auth import PlainTextAuthProvider
from cassandra.cluster import Cluster
from cassandra.util import uuid_from_time
from cassandra import InvalidRequest
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):

View File

@ -20,11 +20,11 @@
import sys
from datetime import datetime
from glances.logger import logger
from glances.exports.export import GlancesExport
import pycouchdb
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the CouchDB export module."""

View File

@ -9,13 +9,13 @@
"""CSV interface class."""
import os.path
import csv
import os.path
import sys
import time
from glances.logger import logger
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):

View File

@ -12,11 +12,11 @@
import sys
from datetime import datetime
from glances.logger import logger
from glances.exports.export import GlancesExport
from elasticsearch import Elasticsearch, helpers
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the ElasticSearch (ES) export module."""

View File

@ -9,17 +9,18 @@
"""Graph exporter interface class."""
from pygal import DateTimeLine
import pygal.style
import sys
import os
import tempfile
import errno
import os
import sys
import tempfile
import pygal.style
from pygal import DateTimeLine
from glances.exports.export import GlancesExport
from glances.globals import iteritems, time_serie_subsample
from glances.logger import logger
from glances.timer import Timer
from glances.globals import iteritems, time_serie_subsample
from glances.exports.export import GlancesExport
class Export(GlancesExport):

View File

@ -12,11 +12,11 @@
import sys
from numbers import Number
from glances.logger import logger
from glances.exports.export import GlancesExport
from graphitesend import GraphiteClient
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the Graphite export module."""

View File

@ -12,12 +12,12 @@
import sys
from platform import node
from glances.logger import logger
from glances.exports.export import GlancesExport
from influxdb import InfluxDBClient
from influxdb.client import InfluxDBClientError
from glances.exports.export import GlancesExport
from glances.logger import logger
FIELD_TO_TAG = ['name', 'cmdline', 'type']

View File

@ -12,11 +12,11 @@
import sys
from platform import node
from glances.logger import logger
from glances.exports.export import GlancesExport
from influxdb_client import InfluxDBClient, WriteOptions
from glances.exports.export import GlancesExport
from glances.logger import logger
FIELD_TO_TAG = ['name', 'cmdline', 'type']

View File

@ -2,9 +2,9 @@
import sys
from glances.globals import listkeys, json_dumps
from glances.logger import logger
from glances.exports.export import GlancesExport
from glances.globals import json_dumps, listkeys
from glances.logger import logger
class Export(GlancesExport):

View File

@ -11,12 +11,12 @@
import sys
from glances.logger import logger
from glances.globals import json_dumps
from glances.exports.export import GlancesExport
from kafka import KafkaProducer
from glances.exports.export import GlancesExport
from glances.globals import json_dumps
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the Kafka export module."""

View File

@ -10,12 +10,12 @@
"""MongoDB interface class."""
import sys
from glances.logger import logger
from glances.exports.export import GlancesExport
from urllib.parse import quote_plus
import pymongo
from urllib.parse import quote_plus
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):

View File

@ -13,14 +13,14 @@ import socket
import string
import sys
from glances.logger import logger
from glances.exports.export import GlancesExport
from glances.globals import json_dumps
# Import paho for MQTT
import certifi
import paho.mqtt.client as paho
from glances.exports.export import GlancesExport
from glances.globals import json_dumps
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the MQTT export module."""

View File

@ -12,11 +12,11 @@
import sys
from numbers import Number
from glances.logger import logger
from glances.exports.export import GlancesExport
import potsdb
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the OpenTSDB export module."""

View File

@ -12,11 +12,11 @@
import sys
from numbers import Number
from glances.logger import logger
from prometheus_client import Gauge, start_http_server
from glances.exports.export import GlancesExport
from glances.globals import iteritems, listkeys
from prometheus_client import start_http_server, Gauge
from glances.logger import logger
class Export(GlancesExport):

View File

@ -14,12 +14,12 @@ import socket
import sys
from numbers import Number
from glances.logger import logger
from glances.exports.export import GlancesExport
# Import pika for RabbitMQ
import pika
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the rabbitMQ export module."""

View File

@ -9,11 +9,11 @@
"""RESTful interface class."""
from requests import post
from glances.exports.export import GlancesExport
from glances.globals import listkeys
from glances.logger import logger
from glances.exports.export import GlancesExport
from requests import post
class Export(GlancesExport):

View File

@ -12,12 +12,12 @@
import socket
from numbers import Number
from glances.logger import logger
from glances.exports.export import GlancesExport
# Import bernhard for Riemann
import bernhard
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the Riemann export module."""

View File

@ -11,11 +11,11 @@
from numbers import Number
from glances.logger import logger
from glances.exports.export import GlancesExport
from statsd import StatsClient
from glances.exports.export import GlancesExport
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the Statsd export module."""

View File

@ -11,14 +11,13 @@
import sys
from glances.globals import b
from glances.logger import logger
from glances.exports.export import GlancesExport
from glances.globals import json_dumps
import zmq
from zmq.utils.strtypes import asbytes
from glances.exports.export import GlancesExport
from glances.globals import b, json_dumps
from glances.logger import logger
class Export(GlancesExport):
"""This class manages the ZeroMQ export module."""

View File

@ -11,10 +11,9 @@
from __future__ import unicode_literals
from glances.timer import Timer
from glances.globals import nativestr, folder_size
from glances.globals import folder_size, nativestr
from glances.logger import logger
from glances.timer import Timer
class FolderList(object):

View File

@ -13,21 +13,21 @@
# GLOBAL IMPORTS
################
import errno
import os
import sys
import platform
import ujson
from operator import itemgetter, methodcaller
import subprocess
from datetime import datetime
import re
import base64
import errno
import functools
import os
import platform
import re
import subprocess
import sys
import weakref
from datetime import datetime
from operator import itemgetter, methodcaller
from statistics import mean
from urllib.request import urlopen, Request
from urllib.request import Request, urlopen
import ujson
# Correct issue #1025 by monkey path the xmlrpc lib
from defusedxml.xmlrpc import monkey_patch

View File

@ -9,13 +9,12 @@
"""Custom logger class."""
import os
import json
import getpass
import tempfile
import json
import logging
import logging.config
import os
import tempfile
from glances.globals import safe_makedirs

View File

@ -15,11 +15,11 @@ import tempfile
from logging import DEBUG
from warnings import simplefilter
from glances import __version__, psutil_version, __apiversion__
from glances.globals import WINDOWS, disable, enable
from glances import __apiversion__, __version__, psutil_version
from glances.config import Config
from glances.globals import WINDOWS, disable, enable
from glances.logger import LOG_FILENAME, logger
from glances.processes import sort_processes_key_list
from glances.logger import logger, LOG_FILENAME
class GlancesMain(object):

View File

@ -9,16 +9,16 @@
"""Manage Glances update."""
from datetime import datetime, timedelta
import threading
import json
import pickle
import os
import pickle
import threading
from datetime import datetime, timedelta
from ssl import CertificateError
from glances import __version__
from glances.globals import nativestr, urlopen, HTTPError, URLError, safe_makedirs
from glances.config import user_cache_dir
from glances.globals import HTTPError, URLError, nativestr, safe_makedirs, urlopen
from glances.logger import logger
try:

View File

@ -11,14 +11,14 @@
from __future__ import unicode_literals
import sys
import getpass
import sys
from glances.globals import MACOS, WINDOWS, nativestr, u, itervalues, enable, disable
from glances.logger import logger
from glances.events_list import glances_events
from glances.processes import glances_processes, sort_processes_key_list
from glances.globals import MACOS, WINDOWS, disable, enable, itervalues, nativestr, u
from glances.logger import logger
from glances.outputs.glances_unicode import unicode_message
from glances.processes import glances_processes, sort_processes_key_list
from glances.timer import Timer
# Import curses library for "normal" operating system

View File

@ -9,11 +9,11 @@
"""Curses browser interface class ."""
import math
import curses
from glances.outputs.glances_curses import _GlancesCurses
import math
from glances.logger import logger
from glances.outputs.glances_curses import _GlancesCurses
from glances.timer import Timer

View File

@ -12,8 +12,8 @@
import os
import sys
import tempfile
from io import open
import webbrowser
from io import open
from urllib.parse import urljoin
try:
@ -23,20 +23,20 @@ except ImportError:
# To be removed when Python 3.8 support will be dropped
from typing_extensions import Annotated
from glances import __version__, __apiversion__
from glances import __apiversion__, __version__
from glances.logger import logger
from glances.password import GlancesPassword
from glances.timer import Timer
from glances.logger import logger
# FastAPI import
try:
from fastapi import FastAPI, Depends, HTTPException, status, APIRouter, Request
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi import APIRouter, Depends, FastAPI, HTTPException, Request, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from fastapi.responses import HTMLResponse, ORJSONResponse
from fastapi.templating import Jinja2Templates
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
except ImportError:
logger.critical('FastAPI import error. Glances cannot start in web server mode.')
sys.exit(2)

View File

@ -9,11 +9,12 @@
"""Manage sparklines for Glances output."""
from __future__ import unicode_literals
from __future__ import division
from __future__ import division, unicode_literals
import sys
from glances.logger import logger
from glances.globals import nativestr
from glances.logger import logger
sparklines_module = True

View File

@ -11,8 +11,8 @@
import time
from glances.logger import logger
from glances.globals import printandflush
from glances.logger import logger
class GlancesStdout(object):

View File

@ -9,14 +9,13 @@
"""Fields description interface class."""
from pprint import pformat
import json
import time
from pprint import pformat
from glances import __apiversion__
from glances.logger import logger
from glances.globals import iteritems
from glances.logger import logger
API_URL = "http://localhost:61208/api/{api_version}".format(api_version=__apiversion__)

View File

@ -10,16 +10,16 @@
"""Issue interface class."""
import os
import sys
import platform
import time
import pprint
from glances.timer import Counter
from glances import __version__, psutil_version
import sys
import time
import psutil
import glances
from glances import __version__, psutil_version
from glances.timer import Counter
TERMINAL_WIDTH = 79

View File

@ -16,8 +16,8 @@ import sys
import uuid
from io import open
from glances.globals import b, safe_makedirs, weak_lru_cache
from glances.config import user_config_dir
from glances.globals import b, safe_makedirs, weak_lru_cache
from glances.logger import logger

View File

@ -9,8 +9,8 @@
"""Monitor plugin."""
from glances.globals import iteritems
from glances.amps_list import AmpsList as glancesAmpsList
from glances.globals import iteritems
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description

View File

@ -17,8 +17,8 @@ Supported Cloud API:
import threading
from glances.globals import iteritems, to_ascii
from glances.plugins.plugin.model import GlancesPluginModel
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
# Import plugin specific dependency
try:

View File

@ -11,11 +11,11 @@
from __future__ import unicode_literals
import psutil
from glances.globals import nativestr
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
from glances.globals import nativestr
import psutil
# Fields description
# description: human readable description

View File

@ -18,8 +18,8 @@ from glances.plugins.containers.stats_streamer import StatsStreamer
# Docker-py library (optional and Linux-only)
# https://github.com/docker/docker-py
try:
import requests
import docker
import requests
from dateutil import parser, tz
except Exception as e:
import_docker_error_tag = True

View File

@ -10,7 +10,7 @@
from datetime import datetime
from glances.globals import iterkeys, itervalues, nativestr, pretty_date, string_value_to_float, replace_special_chars
from glances.globals import iterkeys, itervalues, nativestr, pretty_date, replace_special_chars, string_value_to_float
from glances.logger import logger
from glances.plugins.containers.stats_streamer import StatsStreamer

View File

@ -9,10 +9,10 @@
"""CPU core plugin."""
from glances.plugins.plugin.model import GlancesPluginModel
import psutil
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description
fields_description = {
'phys': {'description': 'Number of physical cores (hyper thread CPUs are excluded).', 'unit': 'number'},

View File

@ -9,13 +9,13 @@
"""CPU plugin."""
from glances.globals import LINUX, WINDOWS, SUNOS, iterkeys
import psutil
from glances.cpu_percent import cpu_percent
from glances.globals import LINUX, SUNOS, WINDOWS, iterkeys
from glances.plugins.core import PluginModel as CorePluginModel
from glances.plugins.plugin.model import GlancesPluginModel
import psutil
# Fields description
# description: human readable description
# short_name: shortname to use un UI

View File

@ -11,12 +11,12 @@
from __future__ import unicode_literals
from glances.logger import logger
from glances.globals import nativestr
from glances.plugins.plugin.model import GlancesPluginModel
import psutil
from glances.globals import nativestr
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description
# description: human readable description
# short_name: shortname to use un UI

View File

@ -11,12 +11,11 @@
from __future__ import unicode_literals
from glances.logger import logger
from glances.globals import nativestr
from glances.folder_list import FolderList as glancesFolderList
from glances.globals import nativestr
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description
# description: human readable description
# short_name: shortname to use un UI

View File

@ -13,12 +13,12 @@ from __future__ import unicode_literals
import operator
from glances.globals import u, nativestr, PermissionError
import psutil
from glances.globals import PermissionError, nativestr, u
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
import psutil
# Fields description
# description: human readable description
# short_name: shortname to use un UI

View File

@ -16,8 +16,8 @@ Currently supported:
"""
from glances.globals import to_fahrenheit
from glances.plugins.gpu.cards.nvidia import NvidiaGPU
from glances.plugins.gpu.cards.amd import AmdGPU
from glances.plugins.gpu.cards.nvidia import NvidiaGPU
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description

View File

@ -35,8 +35,8 @@ See: https://wiki.archlinux.org/title/AMDGPU#Manually
# └── 0
# └── amdgpu_pm_info
import re
import os
import re
DRM_ROOT_FOLDER: str = '/sys/class/drm'
CARD_REGEX: str = r"^card\d$"

View File

@ -9,8 +9,8 @@
"""NVidia Extension unit for Glances' GPU plugin."""
from glances.logger import logger
from glances.globals import nativestr
from glances.logger import logger
try:
import pynvml

View File

@ -14,11 +14,12 @@ Just a stupid plugin to display the help screen.
"""
import sys
from glances.globals import iteritems
from glances import __version__, psutil_version
from glances.plugins.plugin.model import GlancesPluginModel
from itertools import chain
from glances import __version__, psutil_version
from glances.globals import iteritems
from glances.plugins.plugin.model import GlancesPluginModel
class PluginModel(GlancesPluginModel):
"""Glances help plugin."""

View File

@ -10,13 +10,13 @@
"""IP plugin."""
import threading
from ujson import loads
from glances.globals import queue, urlopen_auth
from glances.logger import logger
from glances.timer import Timer
from glances.timer import getTimeSinceLastUpdate
from glances.plugins.plugin.model import GlancesPluginModel
from glances.timer import Timer, getTimeSinceLastUpdate
# Import plugin specific dependency
try:

View File

@ -9,14 +9,13 @@
"""IRQ plugin."""
import os
import operator
import os
from glances.logger import logger
from glances.globals import LINUX
from glances.timer import getTimeSinceLastUpdate
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
from glances.timer import getTimeSinceLastUpdate
# Fields description
# description: human readable description

View File

@ -10,12 +10,13 @@
"""Load plugin."""
import os
import psutil
from glances.globals import iteritems
from glances.logger import logger
from glances.plugins.core import PluginModel as CorePluginModel
from glances.plugins.plugin.model import GlancesPluginModel
from glances.logger import logger
# Fields description
fields_description = {

View File

@ -9,10 +9,10 @@
"""Virtual memory plugin."""
from glances.plugins.plugin.model import GlancesPluginModel
import psutil
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description
fields_description = {
'total': {'description': 'Total physical memory available.', 'unit': 'bytes', 'min_symbol': 'K'},

View File

@ -9,12 +9,12 @@
"""Swap memory plugin."""
from glances.globals import iterkeys
from glances.timer import getTimeSinceLastUpdate
from glances.plugins.plugin.model import GlancesPluginModel
import psutil
from glances.globals import iterkeys
from glances.plugins.plugin.model import GlancesPluginModel
from glances.timer import getTimeSinceLastUpdate
# Fields description
fields_description = {
'total': {'description': 'Total swap memory.', 'unit': 'bytes', 'min_symbol': 'K'},

View File

@ -11,11 +11,11 @@
from __future__ import unicode_literals
from glances.plugins.plugin.model import GlancesPluginModel
from glances.logger import logger
import psutil
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description
# description: human readable description
# short_name: shortname to use un UI

View File

@ -9,8 +9,9 @@
"""Now (current date) plugin."""
from time import tzname, strftime
import datetime
from time import strftime, tzname
from glances.plugins.plugin.model import GlancesPluginModel
# Fields description

View File

@ -13,18 +13,17 @@ I am your father...
...of all Glances model plugins.
"""
import re
import copy
import re
from glances.globals import iterkeys, itervalues, listkeys, mean, nativestr, json_dumps, json_dumps_dictlist, dictlist
from glances.actions import GlancesActions
from glances.events_list import glances_events
from glances.globals import dictlist, iterkeys, itervalues, json_dumps, json_dumps_dictlist, listkeys, mean, nativestr
from glances.history import GlancesHistory
from glances.logger import logger
from glances.events_list import glances_events
from glances.outputs.glances_unicode import unicode_message
from glances.thresholds import glances_thresholds
from glances.timer import Counter, Timer, getTimeSinceLastUpdate
from glances.outputs.glances_unicode import unicode_message
fields_unit_short = {'percent': '%'}

View File

@ -9,19 +9,19 @@
"""Ports scanner plugin."""
import numbers
import os
import socket
import subprocess
import threading
import socket
import time
import numbers
from glances.globals import WINDOWS, MACOS, BSD, bool_type
from glances.ports_list import GlancesPortsList
from glances.web_list import GlancesWebList
from glances.timer import Counter
from glances.globals import BSD, MACOS, WINDOWS, bool_type
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
from glances.ports_list import GlancesPortsList
from glances.timer import Counter
from glances.web_list import GlancesWebList
try:
import requests

View File

@ -9,8 +9,8 @@
"""Process count plugin."""
from glances.processes import glances_processes, sort_for_human
from glances.plugins.plugin.model import GlancesPluginModel
from glances.processes import glances_processes, sort_for_human
# Fields description
# description: human readable description

View File

@ -9,15 +9,15 @@
"""Process list plugin."""
import os
import copy
import os
from glances.logger import logger
from glances.globals import WINDOWS, key_exist_value_not_none_not_v, replace_special_chars
from glances.processes import glances_processes, sort_stats
from glances.logger import logger
from glances.outputs.glances_unicode import unicode_message
from glances.plugins.core import PluginModel as CorePluginModel
from glances.plugins.plugin.model import GlancesPluginModel
from glances.processes import glances_processes, sort_stats
# Fields description
# description: human readable description

View File

@ -9,15 +9,15 @@
"""Quicklook plugin."""
from glances.logger import logger
import psutil
from glances.cpu_percent import cpu_percent
from glances.plugins.load import get_load_average, get_nb_log_core, get_nb_phys_core
from glances.logger import logger
from glances.outputs.glances_bars import Bar
from glances.outputs.glances_sparklines import Sparkline
from glances.plugins.load import get_load_average, get_nb_log_core, get_nb_phys_core
from glances.plugins.plugin.model import GlancesPluginModel
import psutil
# Fields description
# description: human readable description
# short_name: shortname to use un UI

View File

@ -9,20 +9,20 @@
"""Sensors plugin."""
from enum import Enum
import warnings
from concurrent.futures import ThreadPoolExecutor
from typing import List, Dict, Literal, Any
from enum import Enum
from typing import Any, Dict, List, Literal
import psutil
import warnings
from glances.logger import logger
from glances.globals import to_fahrenheit
from glances.timer import Counter
from glances.plugins.sensors.sensor.glances_batpercent import PluginModel as BatPercentPluginModel
from glances.plugins.sensors.sensor.glances_hddtemp import PluginModel as HddTempPluginModel
from glances.logger import logger
from glances.outputs.glances_unicode import unicode_message
from glances.plugins.plugin.model import GlancesPluginModel
from glances.plugins.sensors.sensor.glances_batpercent import PluginModel as BatPercentPluginModel
from glances.plugins.sensors.sensor.glances_hddtemp import PluginModel as HddTempPluginModel
from glances.timer import Counter
class SensorType(str, Enum):

View File

@ -11,9 +11,9 @@
import psutil
from glances.globals import LINUX
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
from glances.globals import LINUX
# Batinfo library (optional; Linux-only)
if LINUX:

View File

@ -34,10 +34,10 @@ Check for admin access. If no admin access, disable SMART plugin.
If smartmontools is not installed, we should catch the error upstream in plugin initialization.
"""
from glances.plugins.plugin.model import GlancesPluginModel
from glances.globals import is_admin
from glances.logger import logger
from glances.main import disable
from glances.globals import is_admin
from glances.plugins.plugin.model import GlancesPluginModel
# Import plugin specific dependency
try:

View File

@ -14,8 +14,8 @@ import platform
import re
from io import open
from glances.logger import logger
from glances.globals import iteritems
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
# {

View File

@ -11,10 +11,10 @@
from datetime import datetime, timedelta
from glances.plugins.plugin.model import GlancesPluginModel
import psutil
from glances.plugins.plugin.model import GlancesPluginModel
# SNMP OID
snmp_oid = {'_uptime': '1.3.6.1.2.1.1.3.0'}

View File

@ -19,9 +19,9 @@ wlp2s0: 0000 51. -59. -256 0 0 0 0 5881 0
import operator
from glances.globals import nativestr, file_exists
from glances.plugins.plugin.model import GlancesPluginModel
from glances.globals import file_exists, nativestr
from glances.logger import logger
from glances.plugins.plugin.model import GlancesPluginModel
# Backup solution is to use the /proc/net/wireless file
# but it only give signal information about the current hotspot

View File

@ -9,8 +9,8 @@
"""Manage the Glances ports list (Ports plugin)."""
from glances.logger import logger
from glances.globals import BSD
from glances.logger import logger
# XXX *BSDs: Segmentation fault (core dumped)
# -- https://bitbucket.org/al45tair/netifaces/issues/15

View File

@ -9,15 +9,14 @@
import os
from glances.globals import BSD, LINUX, MACOS, WINDOWS, iterkeys
from glances.globals import namedtuple_to_dict, list_of_namedtuple_to_list_of_dict
from glances.timer import Timer, getTimeSinceLastUpdate
from glances.filter import GlancesFilterList, GlancesFilter
from glances.programs import processes_to_programs
from glances.logger import logger
import psutil
from glances.filter import GlancesFilter, GlancesFilterList
from glances.globals import BSD, LINUX, MACOS, WINDOWS, iterkeys, list_of_namedtuple_to_list_of_dict, namedtuple_to_dict
from glances.logger import logger
from glances.programs import processes_to_programs
from glances.timer import Timer, getTimeSinceLastUpdate
psutil_version_info = tuple([int(num) for num in psutil.__version__.split('.')])
# This constant defines the list of available processes sort key

View File

@ -9,8 +9,8 @@
"""Secures functions for Glances"""
from subprocess import Popen, PIPE
import re
from subprocess import PIPE, Popen
from glances.globals import nativestr

View File

@ -9,14 +9,13 @@
"""Manage the Glances server."""
from glances.globals import json_dumps
import socket
import sys
from base64 import b64decode
from glances import __version__
from glances.globals import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
from glances.autodiscover import GlancesAutoDiscoverClient
from glances.globals import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer, json_dumps
from glances.logger import logger
from glances.stats_server import GlancesStatsServer
from glances.timer import Timer

View File

@ -12,18 +12,17 @@
import sys
import time
from glances.logger import logger
from glances.globals import WINDOWS
from glances.processes import glances_processes
from glances.stats import GlancesStats
from glances.logger import logger
from glances.outdated import Outdated
from glances.outputs.glances_curses import GlancesCursesStandalone
from glances.outputs.glances_stdout import GlancesStdout
from glances.outputs.glances_stdout_json import GlancesStdoutJson
from glances.outputs.glances_stdout_apidoc import GlancesStdoutApiDoc
from glances.outputs.glances_stdout_csv import GlancesStdoutCsv
from glances.outputs.glances_stdout_issue import GlancesStdoutIssue
from glances.outputs.glances_stdout_apidoc import GlancesStdoutApiDoc
from glances.outdated import Outdated
from glances.outputs.glances_stdout_json import GlancesStdoutJson
from glances.processes import glances_processes
from glances.stats import GlancesStats
from glances.timer import Counter

View File

@ -11,14 +11,14 @@
import collections
import os
import pathlib
import sys
import threading
import traceback
from importlib import import_module
import pathlib
from glances.logger import logger
from glances.globals import exports_path, plugins_path, sys_path
from glances.logger import logger
from glances.timer import Counter

View File

@ -11,9 +11,9 @@
import sys
from glances.stats import GlancesStats
from glances.globals import sys_path
from glances.logger import logger
from glances.stats import GlancesStats
class GlancesStatsClient(GlancesStats):

View File

@ -11,9 +11,9 @@
import re
from glances.stats import GlancesStats
from glances.globals import iteritems
from glances.logger import logger
from glances.stats import GlancesStats
# SNMP OID regexp pattern to short system name dict
oid_to_short_system_name = {

View File

@ -11,8 +11,8 @@
import collections
from glances.stats import GlancesStats
from glances.logger import logger
from glances.stats import GlancesStats
class GlancesStatsServer(GlancesStats):

View File

@ -9,8 +9,8 @@
"""The timer manager."""
from time import time
from datetime import datetime
from time import time
# Global list to manage the elapsed time
last_update_times = {}

View File

@ -10,9 +10,9 @@
"""Glances Restful/API and Web based interface."""
from glances.globals import WINDOWS
from glances.outputs.glances_restful_api import GlancesRestfulApi
from glances.processes import glances_processes
from glances.stats import GlancesStats
from glances.outputs.glances_restful_api import GlancesRestfulApi
class GlancesWebServer(object):

View File

@ -12,7 +12,20 @@ quote-style = "preserve"
[tool.ruff.lint]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
select = [
# "C90", # mccabe
"E", # pycodestyle
"F", # Pyflakes
"I", # isort
# "N", # pep8-naming
"W", # pycodestyle
# "UP", # pyupgrde
# "C4", # flake8-comprehensions
# "RET", # flake8-return
# "FBT", # flake8-boolean-trap
# "RUF", # Ruff-specific rules
# "PERF", # Perflint
]
ignore = []
# Allow autofix for all enabled rules (when `--fix`) is provided.
@ -50,4 +63,4 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
max-complexity = 18

1
run.py
View File

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import re
import sys
from glances import main
if __name__ == '__main__':

View File

@ -6,7 +6,7 @@ import re
import sys
from io import open
from setuptools import setup, Command
from setuptools import Command, setup
# Predication warning
# Glances version 4 will only be compatible with Python 3.7 and above

View File

@ -10,31 +10,33 @@
"""Glances unitary tests suite."""
import json
import sys
import time
import unittest
import sys
import json
# Check Python version
if sys.version_info < (3, 8):
print('Glances requires at least Python 3.8 to run.')
sys.exit(1)
from glances.main import GlancesMain
from glances.stats import GlancesStats
from glances import __version__
from glances.globals import WINDOWS, LINUX, subsample, string_value_to_float
from glances.events_list import GlancesEventsList
from glances.filter import GlancesFilter, GlancesFilterList
from glances.globals import LINUX, WINDOWS, string_value_to_float, subsample
from glances.main import GlancesMain
from glances.outputs.glances_bars import Bar
from glances.thresholds import GlancesThresholdOk
from glances.thresholds import GlancesThresholdCareful
from glances.thresholds import GlancesThresholdWarning
from glances.thresholds import GlancesThresholdCritical
from glances.thresholds import GlancesThresholds
from glances.plugins.plugin.model import GlancesPluginModel
from glances.programs import processes_to_programs
from glances.secure import secure_popen
from glances.events_list import GlancesEventsList
from glances.filter import GlancesFilterList, GlancesFilter
from glances.stats import GlancesStats
from glances.thresholds import (
GlancesThresholdCareful,
GlancesThresholdCritical,
GlancesThresholdOk,
GlancesThresholds,
GlancesThresholdWarning,
)
# Global variables
# =================

View File

@ -10,18 +10,18 @@
"""Glances unitary tests suite for the RESTful API."""
import numbers
import os
import shlex
import subprocess
import time
import numbers
import unittest
from glances.outputs.glances_restful_api import GlancesRestfulApi
import requests
from glances import __version__
from glances.globals import text_type
import requests
from glances.outputs.glances_restful_api import GlancesRestfulApi
SERVER_PORT = 61234
API_VERSION = GlancesRestfulApi.API_VERSION

View File

@ -10,8 +10,8 @@
"""Glances unitary tests suite for the XML-RPC API."""
import os
import json
import os
import shlex
import subprocess
import time