summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glances/README.txt1
-rw-r--r--glances/amps/glances_amp.py2
-rw-r--r--glances/amps/glances_default.py2
-rw-r--r--glances/amps/glances_systemd.py2
-rw-r--r--glances/amps/glances_systemv.py2
-rw-r--r--glances/amps_list.py5
-rw-r--r--glances/client.py2
-rw-r--r--glances/client_browser.py2
-rw-r--r--glances/compat.py212
-rw-r--r--glances/config.py3
-rw-r--r--glances/events.py3
-rw-r--r--glances/exports/glances_cassandra.py2
-rw-r--r--glances/exports/glances_csv.py2
-rw-r--r--glances/exports/glances_export.py2
-rw-r--r--glances/exports/glances_graph.py2
-rw-r--r--glances/exports/glances_graphite.py1
-rw-r--r--glances/exports/glances_json.py2
-rw-r--r--glances/exports/glances_kafka.py2
-rw-r--r--glances/exports/glances_opentsdb.py1
-rw-r--r--glances/exports/glances_prometheus.py2
-rw-r--r--glances/exports/glances_rabbitmq.py1
-rw-r--r--glances/exports/glances_restful.py2
-rw-r--r--glances/exports/glances_riemann.py1
-rw-r--r--glances/exports/glances_statsd.py1
-rw-r--r--glances/exports/glances_zeromq.py2
-rw-r--r--glances/folder_list.py2
-rw-r--r--glances/globals.py206
-rw-r--r--glances/logger.py3
-rw-r--r--glances/main.py3
-rw-r--r--glances/outdated.py3
-rw-r--r--glances/outputs/glances_bottle.py2
-rw-r--r--glances/outputs/glances_curses.py3
-rw-r--r--glances/outputs/glances_sparklines.py2
-rw-r--r--glances/outputs/glances_stdout.py2
-rw-r--r--glances/outputs/glances_stdout_apidoc.py2
-rw-r--r--glances/outputs/glances_stdout_csv.py2
-rw-r--r--glances/outputs/glances_stdout_issue.py2
-rw-r--r--glances/password.py3
-rw-r--r--glances/plugins/amps/__init__.py2
-rw-r--r--glances/plugins/cloud/__init__.py2
-rw-r--r--glances/plugins/connections/__init__.py2
-rw-r--r--glances/plugins/cpu/__init__.py3
-rw-r--r--glances/plugins/diskio/__init__.py2
-rw-r--r--glances/plugins/docker/__init__.py2
-rw-r--r--glances/plugins/folders/__init__.py2
-rw-r--r--glances/plugins/fs/__init__.py2
-rw-r--r--glances/plugins/glances_plugin.py2
-rw-r--r--glances/plugins/glances_sensors.py2
-rw-r--r--glances/plugins/gpu/__init__.py2
-rw-r--r--glances/plugins/ip/__init__.py2
-rw-r--r--glances/plugins/load/__init__.py2
-rw-r--r--glances/plugins/mem/__init__.py2
-rw-r--r--glances/plugins/memswap/__init__.py2
-rw-r--r--glances/plugins/network/__init__.py2
-rw-r--r--glances/plugins/ports/__init__.py3
-rw-r--r--glances/plugins/processlist/__init__.py3
-rw-r--r--glances/plugins/raid/__init__.py2
-rw-r--r--glances/plugins/sensors/glances_hddtemp.py2
-rw-r--r--glances/plugins/smart/__init__.py2
-rw-r--r--glances/plugins/system/__init__.py2
-rw-r--r--glances/plugins/wifi/__init__.py2
-rw-r--r--glances/ports_list.py1
-rw-r--r--glances/processes.py3
-rw-r--r--glances/secure.py2
-rw-r--r--glances/server.py2
-rw-r--r--glances/static_list.py1
-rw-r--r--glances/stats_client_snmp.py2
-rw-r--r--glances/web_list.py12
-rwxr-xr-xunitest-restful.py2
-rwxr-xr-xunitest-xmlrpc.py2
-rwxr-xr-xunitest.py5
71 files changed, 274 insertions, 301 deletions
diff --git a/glances/README.txt b/glances/README.txt
index 74782fc7..c5fd13eb 100644
--- a/glances/README.txt
+++ b/glances/README.txt
@@ -8,7 +8,6 @@ https://glances.readthedocs.io/en/stable/
__init__.py Global module init
__main__.py Entry point for Glances module
config.py Manage the configuration file
-compat.py Python2/3 compatibility shims module
globals.py Share variables upon modules
main.py Main script to rule them up...
client.py Glances client
diff --git a/glances/amps/glances_amp.py b/glances/amps/glances_amp.py
index ccbee541..5e6f31ac 100644
--- a/glances/amps/glances_amp.py
+++ b/glances/amps/glances_amp.py
@@ -32,7 +32,7 @@ The return string is a string with one or more line (\n between lines).
If the *one_line* var is true then the AMP will be displayed in one line.
"""
-from glances.compat import u, b, n, nativestr
+from glances.globals import u, b, n, nativestr
from glances.timer import Timer
from glances.logger import logger
diff --git a/glances/amps/glances_default.py b/glances/amps/glances_default.py
index d942939a..faa49718 100644
--- a/glances/amps/glances_default.py
+++ b/glances/amps/glances_default.py
@@ -37,7 +37,7 @@ command=foo status
from subprocess import check_output, STDOUT, CalledProcessError
-from glances.compat import u, to_ascii
+from glances.globals import u, to_ascii
from glances.logger import logger
from glances.amps.glances_amp import GlancesAmp
diff --git a/glances/amps/glances_systemd.py b/glances/amps/glances_systemd.py
index 993bfefc..5e34d90d 100644
--- a/glances/amps/glances_systemd.py
+++ b/glances/amps/glances_systemd.py
@@ -48,7 +48,7 @@ systemctl_cmd=/usr/bin/systemctl --plain
from subprocess import check_output, CalledProcessError
from glances.logger import logger
-from glances.compat import iteritems, to_ascii
+from glances.globals import iteritems, to_ascii
from glances.amps.glances_amp import GlancesAmp
diff --git a/glances/amps/glances_systemv.py b/glances/amps/glances_systemv.py
index c28a4fde..836427e8 100644
--- a/glances/amps/glances_systemv.py
+++ b/glances/amps/glances_systemv.py
@@ -47,7 +47,7 @@ service_cmd=/usr/bin/service --status-all
from subprocess import check_output, STDOUT
from glances.logger import logger
-from glances.compat import iteritems
+from glances.globals import iteritems
from glances.amps.glances_amp import GlancesAmp
diff --git a/glances/amps_list.py b/glances/amps_list.py
index 1837aec4..90b34184 100644
--- a/glances/amps_list.py
+++ b/glances/amps_list.py
@@ -23,9 +23,8 @@ import os
import re
import threading
-from glances.compat import listkeys, iteritems
+from glances.globals import listkeys, iteritems, amps_path
from glances.logger import logger
-from glances.globals import amps_path
from glances.processes import glances_processes
@@ -112,7 +111,7 @@ class AmpsList(object):
if not v.enable():
# Do not update if the enable tag is set
continue
-
+
if v.regex() is None:
# If there is no regex, execute anyway (see issue #1690)
v.set_count(0)
diff --git a/glances/client.py b/glances/client.py
index 139106ad..264f7e56 100644
--- a/glances/client.py
+++ b/glances/client.py
@@ -24,7 +24,7 @@ import socket
import sys
from glances import __version__
-from glances.compat import Fault, ProtocolError, ServerProxy, Transport
+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
diff --git a/glances/client_browser.py b/glances/client_browser.py
index 7eb0c2bb..94ab80b4 100644
--- a/glances/client_browser.py
+++ b/glances/client_browser.py
@@ -23,7 +23,7 @@ import json
import socket
import threading
-from glances.compat import Fault, ProtocolError, ServerProxy
+from glances.globals import Fault, ProtocolError, ServerProxy
from glances.client import GlancesClient, GlancesClientTransport
from glances.logger import logger, LOG_FILENAME
from glances.password_list import GlancesPasswordList as GlancesPassword
diff --git a/glances/compat.py b/glances/compat.py
deleted file mode 100644
index 58952fc2..00000000
--- a/glances/compat.py
+++ /dev/null
@@ -1,212 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# This file is part of Glances.
-#
-# Copyright (C) 2021 Nicolargo <nicolas@nicolargo.com>
-#
-# Glances is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Glances is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# flake8: noqa
-# pylint: skip-file
-
-# TODO: merge this file with the globals.py
-# Not needed anymore because only Python 3 is supported.
-
-from __future__ import print_function, unicode_literals
-
-import operator
-import sys
-import unicodedata
-import types
-import subprocess
-import os
-
-from glances.logger import logger
-
-import queue
-from configparser import ConfigParser, NoOptionError, NoSectionError
-from statistics import mean
-from xmlrpc.client import Fault, ProtocolError, ServerProxy, Transport, Server
-from xmlrpc.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
-from urllib.request import urlopen
-from urllib.error import HTTPError, URLError
-from urllib.parse import urlparse
-
-# Correct issue #1025 by monkey path the xmlrpc lib
-from defusedxml.xmlrpc import monkey_patch
-monkey_patch()
-
-input = input
-range = range
-map = map
-
-text_type = str
-binary_type = bytes
-bool_type = bool
-long = int
-
-PermissionError = OSError
-
-viewkeys = operator.methodcaller('keys')
-viewvalues = operator.methodcaller('values')
-viewitems = operator.methodcaller('items')
-
-def printandflush(string):
- """Print and flush (used by stdout* outputs modules)"""
- print(string, flush=True)
-
-def to_ascii(s):
- """Convert the bytes string to a ASCII string
- Usefull to remove accent (diacritics)"""
- if isinstance(s, binary_type):
- return s.decode()
- return s.encode('ascii', 'ignore').decode()
-
-def listitems(d):
- return list(d.items())
-
-def listkeys(d):
- return list(d.keys())
-
-def listvalues(d):
- return list(d.values())
-
-def iteritems(d):
- return iter(d.items())
-
-def iterkeys(d):
- return iter(d.keys())
-
-def itervalues(d):
- return iter(d.values())
-
-def u(s, errors='replace'):
- if isinstance(s, text_type):
- return s
- return s.decode('utf-8', errors=errors)
-
-def b(s, errors='replace'):
- if isinstance(s, binary_type):
- return s
- return s.encode('utf-8', errors=errors)
-
-def n(s):
- '''Only in Python 2...
- from future.utils import bytes_to_native_str as n
- '''
- return s
-
-def nativestr(s, errors='replace'):
- if isinstance(s, text_type):
- return s
- elif isinstance(s, (int, float)):
- return s.__str__()
- else:
- return s.decode('utf-8', errors=errors)
-
-def system_exec(command):
- """Execute a system command and return the result as a str"""
- try:
- res = subprocess.run(command.split(' '),
- stdout=subprocess.PIPE).stdout.decode('utf-8')
- except Exception as e:
- logger.debug('Can not evaluate command {} ({})'.format(command, e))
- res = ''
- return res.rstrip()
-
-
-def subsample(data, sampling):
- """Compute a simple mean subsampling.
-
- Data should be a list of numerical itervalues
-
- Return a subsampled list of sampling lenght
- """
- if len(data) <= sampling:
- return data
- sampling_length = int(round(len(data) / float(sampling)))
- return [mean(data[s * sampling_length:(s + 1) * sampling_length]) for s in range(0, sampling)]
-
-
-def time_serie_subsample(data, sampling):
- """Compute a simple mean subsampling.
-
- Data should be a list of set (time, value)
-
- Return a subsampled list of sampling length
- """
- if len(data) <= sampling:
- return data
- t = [t[0] for t in data]
- v = [t[1] for t in data]
- sampling_length = int(round(len(data) / float(sampling)))
- t_subsampled = [t[s * sampling_length:(s + 1) * sampling_length][0] for s in range(0, sampling)]
- v_subsampled = [mean(v[s * sampling_length:(s + 1) * sampling_length]) for s in range(0, sampling)]
- return list(zip(t_subsampled, v_subsampled))
-
-
-def to_fahrenheit(celsius):
- """Convert Celsius to Fahrenheit."""
- return celsius * 1.8 + 32
-
-
-def is_admin():
- """
- https://stackoverflow.com/a/19719292
- @return: True if the current user is an 'Admin' whatever that
- means (root on Unix), otherwise False.
- Warning: The inner function fails unless you have Windows XP SP2 or
- higher. The failure causes a traceback to be printed and this
- function to return False.
- """
-
- if os.name == 'nt':
- import ctypes
- import traceback
- # WARNING: requires Windows XP SP2 or higher!
- try:
- return ctypes.windll.shell32.IsUserAnAdmin()
- except Exception as e:
- traceback.print_exc()
- return False
- else:
- # Check for root on Posix
- return os.getuid() == 0
-
-
-def key_exist_value_not_none(k, d):
- # Return True if:
- # - key k exists
- # - d[k] is not None
- return k in d and d[k] is not N