aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKurt Haenen <Misterke@users.noreply.github.com>2022-06-20 18:10:57 +0200
committerGitHub <noreply@github.com>2022-06-20 12:10:57 -0400
commitf2a5800cea0d87952af1a3e079eea9b3a7aaf43c (patch)
tree019b9e2691c2a3acef5b85b39c019b0a5a514a5f /klippy
parent6af931c4e1c5bf6f9590d0d6ad13d76e2594de77 (diff)
downloadkutter-f2a5800cea0d87952af1a3e079eea9b3a7aaf43c.tar.gz
kutter-f2a5800cea0d87952af1a3e079eea9b3a7aaf43c.tar.xz
kutter-f2a5800cea0d87952af1a3e079eea9b3a7aaf43c.zip
configfile: Expose options awaiting to be saved (#5270)
Adds a save_config_pending_items to the status reported by configfile reflecting the items and values that a future SAVE_CONFIG would actually persist. Signed-off-by: Kurt Haenen <kurt.haenen@gmail.com>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/configfile.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/klippy/configfile.py b/klippy/configfile.py
index 165e9320..63dd8149 100644
--- a/klippy/configfile.py
+++ b/klippy/configfile.py
@@ -140,6 +140,7 @@ class PrinterConfig:
self.autosave = None
self.deprecated = {}
self.status_raw_config = {}
+ self.status_save_pending = {}
self.status_settings = {}
self.status_warnings = []
self.save_config_pending = False
@@ -331,18 +332,36 @@ class PrinterConfig:
return {'config': self.status_raw_config,
'settings': self.status_settings,
'warnings': self.status_warnings,
- 'save_config_pending': self.save_config_pending}
+ 'save_config_pending': self.save_config_pending,
+ 'save_config_pending_items': self.status_save_pending}
# Autosave functions
def set(self, section, option, value):
if not self.autosave.fileconfig.has_section(section):
self.autosave.fileconfig.add_section(section)
svalue = str(value)
self.autosave.fileconfig.set(section, option, svalue)
+ pending = dict(self.status_save_pending)
+ if not section in pending or pending[section] is None:
+ pending[section] = {}
+ else:
+ pending[section] = dict(pending[section])
+ pending[section][option] = svalue
+ self.status_save_pending = pending
self.save_config_pending = True
logging.info("save_config: set [%s] %s = %s", section, option, svalue)
def remove_section(self, section):
- self.autosave.fileconfig.remove_section(section)
- self.save_config_pending = True
+ if self.autosave.fileconfig.has_section(section):
+ self.autosave.fileconfig.remove_section(section)
+ pending = dict(self.status_save_pending)
+ pending[section] = None
+ self.status_save_pending = pending
+ self.save_config_pending = True
+ elif (section in self.status_save_pending and
+ self.status_save_pending[section] is not None):
+ pending = dict(self.status_save_pending)
+ del pending[section]
+ self.status_save_pending = pending
+ self.save_config_pending = True
def _disallow_include_conflicts(self, regular_data, cfgname, gcode):
config = self._build_config_wrapper(regular_data, cfgname)
for section in self.autosave.fileconfig.sections():