mirror of
https://github.com/nicolargo/glances.git
synced 2024-08-16 07:50:40 +03:00
Replace UJson by ORJson - Client/Server do not work anymore
This commit is contained in:
parent
d2f1fa10d5
commit
ba88263b85
@ -86,7 +86,7 @@ Requirements
|
|||||||
- ``psutil`` (better with latest version)
|
- ``psutil`` (better with latest version)
|
||||||
- ``defusedxml`` (in order to monkey patch xmlrpc)
|
- ``defusedxml`` (in order to monkey patch xmlrpc)
|
||||||
- ``packaging`` (for the version comparison)
|
- ``packaging`` (for the version comparison)
|
||||||
- ``ujson`` (an optimized alternative to the standard json module)
|
- ``orjson`` (an optimized alternative to the standard json module)
|
||||||
|
|
||||||
*Note for Python 2 users*
|
*Note for Python 2 users*
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
orjson
|
||||||
reuse
|
reuse
|
||||||
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
|
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
|
||||||
sphinx
|
sphinx
|
||||||
sphinx_rtd_theme
|
sphinx_rtd_theme
|
||||||
ujson
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import ujson
|
import orjson
|
||||||
|
|
||||||
from glances import __version__
|
from glances import __version__
|
||||||
from glances.globals import Fault, ProtocolError, ServerProxy, Transport
|
from glances.globals import Fault, ProtocolError, ServerProxy, Transport
|
||||||
@ -118,7 +118,7 @@ class GlancesClient:
|
|||||||
if __version__.split('.')[0] == client_version.split('.')[0]:
|
if __version__.split('.')[0] == client_version.split('.')[0]:
|
||||||
# Init stats
|
# Init stats
|
||||||
self.stats = GlancesStatsClient(config=self.config, args=self.args)
|
self.stats = GlancesStatsClient(config=self.config, args=self.args)
|
||||||
self.stats.set_plugins(ujson.loads(self.client.getAllPlugins()))
|
self.stats.set_plugins(orjson.loads(self.client.getAllPlugins()))
|
||||||
logger.debug(f"Client version: {__version__} / Server version: {client_version}")
|
logger.debug(f"Client version: {__version__} / Server version: {client_version}")
|
||||||
else:
|
else:
|
||||||
self.log_and_exit(
|
self.log_and_exit(
|
||||||
@ -195,7 +195,7 @@ class GlancesClient:
|
|||||||
"""
|
"""
|
||||||
# Update the stats
|
# Update the stats
|
||||||
try:
|
try:
|
||||||
server_stats = ujson.loads(self.client.getAll())
|
server_stats = orjson.loads(self.client.getAll())
|
||||||
except OSError:
|
except OSError:
|
||||||
# Client cannot get server stats
|
# Client cannot get server stats
|
||||||
return "Disconnected"
|
return "Disconnected"
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import ujson
|
import orjson
|
||||||
|
|
||||||
from glances.autodiscover import GlancesAutoDiscoverServer
|
from glances.autodiscover import GlancesAutoDiscoverServer
|
||||||
from glances.client import GlancesClient, GlancesClientTransport
|
from glances.client import GlancesClient, GlancesClientTransport
|
||||||
@ -95,12 +95,12 @@ class GlancesClientBrowser:
|
|||||||
# Mandatory stats
|
# Mandatory stats
|
||||||
try:
|
try:
|
||||||
# CPU%
|
# CPU%
|
||||||
cpu_percent = 100 - ujson.loads(s.getCpu())['idle']
|
cpu_percent = 100 - orjson.loads(s.getCpu())['idle']
|
||||||
server['cpu_percent'] = f'{cpu_percent:.1f}'
|
server['cpu_percent'] = f'{cpu_percent:.1f}'
|
||||||
# MEM%
|
# MEM%
|
||||||
server['mem_percent'] = ujson.loads(s.getMem())['percent']
|
server['mem_percent'] = orjson.loads(s.getMem())['percent']
|
||||||
# OS (Human Readable name)
|
# OS (Human Readable name)
|
||||||
server['hr_name'] = ujson.loads(s.getSystem())['hr_name']
|
server['hr_name'] = orjson.loads(s.getSystem())['hr_name']
|
||||||
except (OSError, Fault, KeyError) as e:
|
except (OSError, Fault, KeyError) as e:
|
||||||
logger.debug(f"Error while grabbing stats form server ({e})")
|
logger.debug(f"Error while grabbing stats form server ({e})")
|
||||||
server['status'] = 'OFFLINE'
|
server['status'] = 'OFFLINE'
|
||||||
@ -120,7 +120,7 @@ class GlancesClientBrowser:
|
|||||||
# Optional stats (load is not available on Windows OS)
|
# Optional stats (load is not available on Windows OS)
|
||||||
try:
|
try:
|
||||||
# LOAD
|
# LOAD
|
||||||
load_min5 = ujson.loads(s.getLoad())['min5']
|
load_min5 = orjson.loads(s.getLoad())['min5']
|
||||||
server['load_min5'] = f'{load_min5:.2f}'
|
server['load_min5'] = f'{load_min5:.2f}'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Error while grabbing stats form server ({e})")
|
logger.warning(f"Error while grabbing stats form server ({e})")
|
||||||
|
@ -33,7 +33,7 @@ from urllib.request import Request, urlopen
|
|||||||
from xmlrpc.client import Fault, ProtocolError, Server, ServerProxy, Transport
|
from xmlrpc.client import Fault, ProtocolError, Server, ServerProxy, Transport
|
||||||
from xmlrpc.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
|
from xmlrpc.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
|
||||||
|
|
||||||
import ujson
|
import orjson
|
||||||
|
|
||||||
# Correct issue #1025 by monkey path the xmlrpc lib
|
# Correct issue #1025 by monkey path the xmlrpc lib
|
||||||
from defusedxml.xmlrpc import monkey_patch
|
from defusedxml.xmlrpc import monkey_patch
|
||||||
@ -309,9 +309,9 @@ def json_dumps(data):
|
|||||||
Manage the issue #815 for Windows OS with UnicodeDecodeError catching.
|
Manage the issue #815 for Windows OS with UnicodeDecodeError catching.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return ujson.dumps(data)
|
return orjson.dumps(data)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return ujson.dumps(data, ensure_ascii=False)
|
return orjson.dumps(data, ensure_ascii=False)
|
||||||
|
|
||||||
|
|
||||||
def dictlist(data, item):
|
def dictlist(data, item):
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from ujson import loads
|
from orjson import loads
|
||||||
|
|
||||||
from glances.globals import queue, urlopen_auth
|
from glances.globals import queue, urlopen_auth
|
||||||
from glances.logger import logger
|
from glances.logger import logger
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
defusedxml
|
defusedxml
|
||||||
|
orjson>=5.4.0
|
||||||
packaging
|
packaging
|
||||||
psutil>=5.6.7
|
psutil>=5.6.7
|
||||||
ujson>=5.4.0
|
|
||||||
|
Loading…
Reference in New Issue
Block a user