Configuration.config.Config

class Configuration.config.Config

Loader for the base device configuration file.

Reads and parses Configuration/config.json on instantiation, making the resulting dictionary available via the config attribute.

Variables:

config (dict) – Parsed contents of config.json. Contains base settings such as sampling intervals, device identifiers, and default parameter configurations shared by all sensor wrappers.

Example

Instantiate the loader and read a configured value:

>>> from Configuration.config import Config
>>> cfg = Config()
>>> isinstance(cfg.config, dict)
True

Note

Construction performs blocking filesystem I/O against Configuration/config.json and is intended to run once at firmware start-up on the target Raspberry Pi device.

Load Configuration/config.json into config.

Resolves the JSON file path relative to this module’s directory, opens it in text mode, parses it with json.load(), and stores the resulting mapping on the instance as config.

Returns:

This initializer mutates instance state and returns nothing.

Return type:

None

Raises:
  • FileNotFoundError – If Configuration/config.json does not exist next to this module on disk.

  • PermissionError – If the process cannot read the configuration file (for example, due to filesystem permissions on the target device).

  • json.JSONDecodeError – If the configuration file contents are not valid JSON.

Example

Construct the loader and access the parsed settings:

>>> from Configuration.config import Config
>>> cfg = Config()
>>> cfg.config
{...}

Note

This method touches the filesystem, so doctest examples that instantiate Config are marked # doctest: +SKIP to keep the test suite hardware- and device-independent.

config: dict