mirror of
				https://github.com/Klipper3d/klipper.git
				synced 2025-10-31 18:36:09 +01:00 
			
		
		
		
	configfile: Add get_status() to export raw config file information
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
		| @@ -180,6 +180,12 @@ The following are common printer attributes: | ||||
|   QUERY_ENDSTOP command. Note, due to the order of template expansion | ||||
|   (see above), the QUERY_STATUS command must be run prior to the macro | ||||
|   containing this reference. | ||||
| - `printer.configfile.config["<section>"]["<option>"]`: Returns the | ||||
|   given config file setting as read by Klipper during the last | ||||
|   software start or restart. (Any settings changed at run-time will | ||||
|   not be reflected here.) All values are returned as strings (if math | ||||
|   is to be performed on the value then it must be converted to a | ||||
|   Python number). | ||||
|  | ||||
| The above list is subject to change - if using an attribute be sure to | ||||
| review the [Config Changes document](Config_Changes.md) when upgrading | ||||
|   | ||||
| @@ -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): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user