summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicolargo <nicolashennion@gmail.com>2024-05-18 14:09:30 +0200
committernicolargo <nicolashennion@gmail.com>2024-05-18 14:09:30 +0200
commitba88263b85bbdc93e7f743fc42be5b4afb774a07 (patch)
tree72a6677190759584f0f206e746a0356d2785ce7b
parentd2f1fa10d57ea9c4b339cff3f0c190e168461155 (diff)
Replace UJson by ORJson - Client/Server do not work anymoreissue2791
-rw-r--r--README.rst2
-rw-r--r--doc-requirements.txt2
-rw-r--r--glances/client.py6
-rw-r--r--glances/client_browser.py10
-rw-r--r--glances/globals.py6
-rw-r--r--glances/plugins/ip/__init__.py2
-rw-r--r--requirements.txt2
-rw-r--r--tox.ini2
8 files changed, 16 insertions, 16 deletions
diff --git a/README.rst b/README.rst
index 5331994d..04a817bf 100644
--- a/README.rst
+++ b/README.rst
@@ -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*
diff --git a/doc-requirements.txt b/doc-requirements.txt
index 804d5398..74d6796a 100644
--- a/doc-requirements.txt
+++ b/doc-requirements.txt
@@ -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
diff --git a/glances/client.py b/glances/client.py
index a73fedb0..308f2061 100644
--- a/glances/client.py
+++ b/glances/client.py
@@ -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"
diff --git a/glances/client_browser.py b/glances/client_browser.py
index 4e98cde4..e337258d 100644
--- a/glances/client_browser.py
+++ b/glances/client_browser.py
@@ -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})")
diff --git a/glances/globals.py b/glances/globals.py
index 56002c38..96d8f781 100644
--- a/glances/globals.py
+++ b/glances/globals.py
@@ -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):
diff --git a/glances/plugins/ip/__init__.py b/glances/plugins/ip/__init__.py
index 6d5f55f2..62a95658 100644
--- a/glances/plugins/ip/__init__.py
+++ b/glances/plugins/ip/__init__.py
@@ -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
diff --git a/requirements.txt b/requirements.txt
index 1b01d13b..c02269a3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
defusedxml
+orjson>=5.4.0
packaging
psutil>=5.6.7
-ujson>=5.4.0
diff --git a/tox.ini b/tox.ini
index e61d733e..aedea68a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -18,7 +18,7 @@ deps =
psutil
defusedxml
packaging
- ujson
+ orjson
fastapi
uvicorn
jinja2