aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-02-13 21:57:41 -0500
committerKevin O'Connor <kevin@koconnor.net>2020-02-13 22:04:40 -0500
commitc3899cefa8d8824f83ff430c025075127adc2aab (patch)
tree93f5c5242c270d528d3297fac260fa1f48cadbed /klippy
parentfd6baa3d161a02a5ca1933fc460070c17429808c (diff)
downloadkutter-c3899cefa8d8824f83ff430c025075127adc2aab.tar.gz
kutter-c3899cefa8d8824f83ff430c025075127adc2aab.tar.xz
kutter-c3899cefa8d8824f83ff430c025075127adc2aab.zip
configfile: Add get_status() to export raw config file information
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/configfile.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/klippy/configfile.py b/klippy/configfile.py
index 11a0edb0..7a7360d3 100644
--- a/klippy/configfile.py
+++ b/klippy/configfile.py
@@ -88,6 +88,7 @@ class PrinterConfig:
def __init__(self, printer):
self.printer = printer
self.autosave = None
+ self.status_info = {}
gcode = self.printer.lookup_object('gcode')
gcode.register_command("SAVE_CONFIG", self.cmd_SAVE_CONFIG,
desc=self.cmd_SAVE_CONFIG_help)
@@ -217,9 +218,9 @@ class PrinterConfig:
regular_config = self._build_config_wrapper(regular_data, filename)
autosave_data = self._strip_duplicates(autosave_data, regular_config)
self.autosave = self._build_config_wrapper(autosave_data, filename)
- self._config = self._build_config_wrapper(regular_data + autosave_data,
- filename)
- return self._config
+ cfg = self._build_config_wrapper(regular_data + autosave_data, filename)
+ self._build_status(cfg)
+ return cfg
def check_unused_options(self, config):
fileconfig = config.fileconfig
objects = dict(self.printer.lookup_objects())
@@ -245,6 +246,15 @@ class PrinterConfig:
self._build_config_string(config),
"======================="]
self.printer.set_rollover_info("config", "\n".join(lines))
+ # Status reporting
+ def _build_status(self, config):
+ self.status_info.clear()
+ for section in config.get_prefix_sections(''):
+ self.status_info[section.get_name()] = section_status = {}
+ for option in section.get_prefix_options(''):
+ section_status[option] = section.get(option)
+ def get_status(self, eventtime):
+ return {'config': self.status_info}
# Autosave functions
def set(self, section, option, value):
if not self.autosave.fileconfig.has_section(section):