def _load_sensors(config):
"""Loads all the sensors from the specified config file.
Args:
config (ConfigParser): instance from which to extract the sensor list.
`str` is also allowed, in which case it
should be the path to the config file to load.
"""
global _sensors, _sensors_parsed
if not _sensors_parsed:
parser = _get_parser(config)
if parser is not None:
#Now that we have the thread, we can add configuration for each of the
#sensors in the config file.
from fnmatch import fnmatch
for section in parser.sections():
if fnmatch(section, "sensor.*"):
name = section[len("sensor."):]
_sensors[name] = Sensor(None,name,**dict(parser.items(section)))
_sensors_parsed = True
评论列表
文章目录