mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-06 01:35:47 +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)
|
||||
- ``defusedxml`` (in order to monkey patch xmlrpc)
|
||||
- ``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*
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
orjson
|
||||
reuse
|
||||
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
|
||||
sphinx
|
||||
sphinx_rtd_theme
|
||||
ujson
|
||||
|
@ -11,7 +11,7 @@
|
||||
import sys
|
||||
import time
|
||||
|
||||
import ujson
|
||||
import orjson
|
||||
|
||||
from glances import __version__
|
||||
from glances.globals import Fault, ProtocolError, ServerProxy, Transport
|
||||
@ -118,7 +118,7 @@ class GlancesClient:
|
||||
if __version__.split('.')[0] == client_version.split('.')[0]:
|
||||
# Init stats
|
||||
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}")
|
||||
else:
|
||||
self.log_and_exit(
|
||||
@ -195,7 +195,7 @@ class GlancesClient:
|
||||
"""
|
||||
# Update the stats
|
||||
try:
|
||||
server_stats = ujson.loads(self.client.getAll())
|
||||
server_stats = orjson.loads(self.client.getAll())
|
||||
except OSError:
|
||||
# Client cannot get server stats
|
||||
return "Disconnected"
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
import threading
|
||||
|
||||
import ujson
|
||||
import orjson
|
||||
|
||||
from glances.autodiscover import GlancesAutoDiscoverServer
|
||||
from glances.client import GlancesClient, GlancesClientTransport
|
||||
@ -95,12 +95,12 @@ class GlancesClientBrowser:
|
||||
# Mandatory stats
|
||||
try:
|
||||
# CPU%
|
||||
cpu_percent = 100 - ujson.loads(s.getCpu())['idle']
|
||||
cpu_percent = 100 - orjson.loads(s.getCpu())['idle']
|
||||
server['cpu_percent'] = f'{cpu_percent:.1f}'
|
||||
# MEM%
|
||||
server['mem_percent'] = ujson.loads(s.getMem())['percent']
|
||||
server['mem_percent'] = orjson.loads(s.getMem())['percent']
|
||||
# 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:
|
||||
logger.debug(f"Error while grabbing stats form server ({e})")
|
||||
server['status'] = 'OFFLINE'
|
||||
@ -120,7 +120,7 @@ class GlancesClientBrowser:
|
||||
# Optional stats (load is not available on Windows OS)
|
||||
try:
|
||||
# LOAD
|
||||
load_min5 = ujson.loads(s.getLoad())['min5']
|
||||
load_min5 = orjson.loads(s.getLoad())['min5']
|
||||
server['load_min5'] = f'{load_min5:.2f}'
|
||||
except Exception as 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.server import SimpleXMLRPCRequestHandler, SimpleXMLRPCServer
|
||||
|
||||
import ujson
|
||||
import orjson
|
||||
|
||||
# Correct issue #1025 by monkey path the xmlrpc lib
|
||||
from defusedxml.xmlrpc import monkey_patch
|
||||
@ -309,9 +309,9 @@ def json_dumps(data):
|
||||
Manage the issue #815 for Windows OS with UnicodeDecodeError catching.
|
||||
"""
|
||||
try:
|
||||
return ujson.dumps(data)
|
||||
return orjson.dumps(data)
|
||||
except UnicodeDecodeError:
|
||||
return ujson.dumps(data, ensure_ascii=False)
|
||||
return orjson.dumps(data, ensure_ascii=False)
|
||||
|
||||
|
||||
def dictlist(data, item):
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
import threading
|
||||
|
||||
from ujson import loads
|
||||
from orjson import loads
|
||||
|
||||
from glances.globals import queue, urlopen_auth
|
||||
from glances.logger import logger
|
||||
|
@ -1,4 +1,4 @@
|
||||
defusedxml
|
||||
orjson>=5.4.0
|
||||
packaging
|
||||
psutil>=5.6.7
|
||||
ujson>=5.4.0
|
||||
|
Loading…
Reference in New Issue
Block a user