Source code for netdef.Sources.SystemMonitorSource

from netdef.Interfaces import UnitOfValueInterface
from netdef.Sources import BaseSource, Sources

bytes2human = UnitOfValueInterface.bytes2human


[docs]@Sources.register("SystemMonitorSource") class SystemMonitorSource(BaseSource.BaseSource): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.interface = self.get_interface()
[docs] @staticmethod def get_interface(): return UnitOfValueInterface.NoUnitInterface
[docs] def get_value_and_unit(self): return self.interface(self.value).get_value_and_unit()
@property def value_as_string(self): "" return str(self.value)
[docs]@Sources.register("SystemMonitorByteSource") class SystemMonitorByteSource(SystemMonitorSource):
[docs] @staticmethod def get_interface(): return UnitOfValueInterface.ByteUnitInterface
[docs]@Sources.register("SystemMonitorPercentSource") class SystemMonitorPercentSource(SystemMonitorSource):
[docs] @staticmethod def get_interface(): return UnitOfValueInterface.PercentUnitInterface