def from_configparser( cls, section: ConfigParserSection, daemon_cli_config: DaemonCLIConfig) -> "DaemonConfig": pidfile = first_not_none( daemon_cli_config.pidfile, section.get("pidfile", fallback=DEFAULT_PIDFILE)) if pidfile is not None and not pidfile.strip(): pidfile = None logfile = first_not_none(daemon_cli_config.logfile, section.get("logfile", fallback=None)) interval = section.getint("interval", fallback=5) exporter_listen_host = first_not_none( daemon_cli_config.exporter_listen_host, section.get("exporter_listen_host", fallback=None), ) return cls( pidfile=pidfile, logfile=logfile, interval=interval, exporter_listen_host=exporter_listen_host, )
def from_configparser(cls, section: ConfigParserSection) -> Temp: panic = TempCelsius(section.getfloat("panic", fallback=None)) threshold = TempCelsius(section.getfloat("threshold", fallback=None)) min = TempCelsius(section.getfloat("min", fallback=None)) max = TempCelsius(section.getfloat("max", fallback=None)) return cls(section["command"], min=min, max=max, panic=panic, threshold=threshold)
def from_configparser(cls, section: ConfigParserSection) -> "Actions": panic = AlertCommands( enter_cmd=section.get("panic_enter_cmd", fallback=None), leave_cmd=section.get("panic_leave_cmd", fallback=None), ) threshold = AlertCommands( enter_cmd=section.get("threshold_enter_cmd", fallback=None), leave_cmd=section.get("threshold_leave_cmd", fallback=None), ) return cls(panic=panic, threshold=threshold)
def from_configparser(cls, section: ConfigParserSection, programs: Programs) -> Temp: panic = TempCelsius(section.getfloat("panic", fallback=None)) threshold = TempCelsius(section.getfloat("threshold", fallback=None)) min = TempCelsius(section.getfloat("min")) max = TempCelsius(section.getfloat("max")) return cls( section["path"], min=min, max=max, panic=panic, threshold=threshold, hddtemp_bin=programs.hddtemp, )
def _parse_actions(config: configparser.ConfigParser) -> Tuple[str, Actions]: section: ConfigParserSection[str] = ConfigParserSection(config["actions"]) report_cmd = section.get("report_cmd", fallback=DEFAULT_REPORT_CMD) actions = Actions.from_configparser(section) section.ensure_no_unused_keys() return report_cmd, actions
def from_configparser(cls, section: ConfigParserSection, programs: Programs) -> BaseFanSpeed: return cls( section["name"], ipmi_sensors_bin=programs.ipmi_sensors, ipmi_sensors_extra_args=section.get("ipmi_sensors_extra_args", fallback=""), )
def from_configparser( cls, section: ConfigParserSection, arduino_connections: Mapping[ArduinoName, ArduinoConnection], ) -> BaseFanPWMRead: arduino_name = ArduinoName(section["arduino_name"]) _ensure_arduino_connection(arduino_name, arduino_connections) pwm_pin = ArduinoPin(section.getint("pwm_pin")) return cls(arduino_connections[arduino_name], pwm_pin=pwm_pin)
def _parse_daemon( config: configparser.ConfigParser, daemon_cli_config: DaemonCLIConfig) -> Tuple[DaemonConfig, Programs]: section: ConfigParserSection[str] = ConfigParserSection(config["daemon"]) daemon_config = DaemonConfig.from_configparser(section, daemon_cli_config) programs = Programs.from_configparser(section) section.ensure_no_unused_keys() return daemon_config, programs
def from_configparser(cls, section: ConfigParserSection) -> "Programs": return cls( hddtemp=section.get("hddtemp", fallback="hddtemp"), ipmi_sensors=section.get("ipmi_sensors", fallback="ipmi-sensors"), )