mirror of
https://github.com/nicolargo/glances.git
synced 2024-08-17 00:10:48 +03:00
Merge pull request #2778 from nicolargo/2777-make-pydantic-dep-optional
chg: event_list - enable data validation only if pydantic available
This commit is contained in:
commit
396e78c415
@ -32,7 +32,13 @@ Item (or event) is defined by:
|
||||
}
|
||||
"""
|
||||
|
||||
from pydantic.dataclasses import dataclass
|
||||
from glances.logger import logger
|
||||
|
||||
try:
|
||||
from pydantic.dataclasses import dataclass
|
||||
except ImportError as e:
|
||||
logger.warning(f"Missing Python Lib ({e}), EventList will be skipping data validation")
|
||||
from dataclasses import dataclass
|
||||
|
||||
from glances.processes import sort_stats
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
import time
|
||||
from datetime import datetime
|
||||
from pydantic import RootModel
|
||||
from dataclasses import asdict
|
||||
|
||||
from glances.processes import glances_processes
|
||||
from glances.thresholds import glances_thresholds
|
||||
@ -201,7 +201,7 @@ class GlancesEventsList(object):
|
||||
|
||||
def get(self):
|
||||
"""Return the RAW events list."""
|
||||
return [RootModel[GlancesEvent](e).model_dump() for e in self.events_list]
|
||||
return [asdict(e) for e in self.events_list]
|
||||
|
||||
def len(self):
|
||||
"""Return the number of events in the logs list."""
|
||||
|
@ -22,6 +22,7 @@ podman; python_version >= "3.6"
|
||||
potsdb
|
||||
prometheus_client
|
||||
pycouchdb
|
||||
pydantic
|
||||
pygal
|
||||
pymdstat
|
||||
pymongo; python_version >= "3.7"
|
||||
|
@ -2,4 +2,3 @@ psutil>=5.6.7
|
||||
defusedxml
|
||||
packaging
|
||||
ujson>=5.4.0
|
||||
pydantic>=2.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user