aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/configfile.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-03-05 21:45:16 -0500
committerKevin O'Connor <kevin@koconnor.net>2024-03-13 21:44:32 -0400
commit0291a1554cb7bb8c74db15591150aa7958905df5 (patch)
treebbf360e5df2dc7aae9dab67133c714f90aa231af /klippy/configfile.py
parentd99d1a84631fb3840132c492bc32fd9579740d1e (diff)
downloadkutter-0291a1554cb7bb8c74db15591150aa7958905df5.tar.gz
kutter-0291a1554cb7bb8c74db15591150aa7958905df5.tar.xz
kutter-0291a1554cb7bb8c74db15591150aa7958905df5.zip
configfile: Add support for reporting runtime_warnings via the API server
Add a new runtime_warning() method that will add a 'runtime_warning' type message to the printer.configfile.warnings object. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/configfile.py')
-rw-r--r--klippy/configfile.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/klippy/configfile.py b/klippy/configfile.py
index f099b563..b1f7d6d6 100644
--- a/klippy/configfile.py
+++ b/klippy/configfile.py
@@ -143,6 +143,8 @@ class PrinterConfig:
self.printer = printer
self.autosave = None
self.deprecated = {}
+ self.runtime_warnings = []
+ self.deprecate_warnings = []
self.status_raw_config = {}
self.status_save_pending = {}
self.status_settings = {}
@@ -314,6 +316,11 @@ class PrinterConfig:
"======================="]
self.printer.set_rollover_info("config", "\n".join(lines))
# Status reporting
+ def runtime_warning(self, msg):
+ logging.warn(msg)
+ res = {'type': 'runtime_warning', 'message': msg}
+ self.runtime_warnings.append(res)
+ self.status_warnings = self.runtime_warnings + self.deprecate_warnings
def deprecate(self, section, option, value=None, msg=None):
self.deprecated[(section, option, value)] = msg
def _build_status(self, config):
@@ -325,7 +332,7 @@ class PrinterConfig:
self.status_settings = {}
for (section, option), value in config.access_tracking.items():
self.status_settings.setdefault(section, {})[option] = value
- self.status_warnings = []
+ self.deprecate_warnings = []
for (section, option, value), msg in self.deprecated.items():
if value is None:
res = {'type': 'deprecated_option'}
@@ -334,7 +341,8 @@ class PrinterConfig:
res['message'] = msg
res['section'] = section
res['option'] = option
- self.status_warnings.append(res)
+ self.deprecate_warnings.append(res)
+ self.status_warnings = self.runtime_warnings + self.deprecate_warnings
def get_status(self, eventtime):
return {'config': self.status_raw_config,
'settings': self.status_settings,