mirror of
https://github.com/nicolargo/glances.git
synced 2024-09-11 12:47:14 +03:00
chg: event_list - enable data validation only if pydantic available
This commit is contained in:
parent
05bc1449db
commit
98f2bb7fbe
@ -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
|
from glances.processes import sort_stats
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pydantic import RootModel
|
from dataclasses import asdict
|
||||||
|
|
||||||
from glances.processes import glances_processes
|
from glances.processes import glances_processes
|
||||||
from glances.thresholds import glances_thresholds
|
from glances.thresholds import glances_thresholds
|
||||||
@ -201,7 +201,7 @@ class GlancesEventsList(object):
|
|||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
"""Return the RAW events list."""
|
"""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):
|
def len(self):
|
||||||
"""Return the number of events in the logs list."""
|
"""Return the number of events in the logs list."""
|
||||||
|
@ -22,6 +22,7 @@ podman; python_version >= "3.6"
|
|||||||
potsdb
|
potsdb
|
||||||
prometheus_client
|
prometheus_client
|
||||||
pycouchdb
|
pycouchdb
|
||||||
|
pydantic
|
||||||
pygal
|
pygal
|
||||||
pymdstat
|
pymdstat
|
||||||
pymongo; python_version >= "3.7"
|
pymongo; python_version >= "3.7"
|
||||||
|
@ -2,4 +2,3 @@ psutil>=5.6.7
|
|||||||
defusedxml
|
defusedxml
|
||||||
packaging
|
packaging
|
||||||
ujson>=5.4.0
|
ujson>=5.4.0
|
||||||
pydantic>=2.0.0
|
|
||||||
|
Loading…
Reference in New Issue
Block a user