Updating the settings now fires a new event "SettingsUpdated"

This commit is contained in:
Gina Häußge 2014-11-17 11:06:54 +01:00
parent 048ad78778
commit 50895a662a
4 changed files with 14 additions and 2 deletions

View file

@ -356,3 +356,9 @@ SlicingFailed
* ``stl``: the STL's filename
* ``gcode``: the sliced GCODE's filename
* ``reason``: the reason for the slicing having failed
Settings
--------
SettingsUpdated
The internal settings were updated.

View file

@ -81,6 +81,9 @@ class Events(object):
SLICING_FAILED = "SlicingFailed"
SLICING_CANCELLED = "SlicingCancelled"
# Settings
SETTINGS_UPDATED = "SettingsUpdated"
def eventManager():
global _instance

View file

@ -9,6 +9,7 @@ import logging
from flask import request, jsonify
from octoprint.events import eventManager, Events
from octoprint.settings import settings
from octoprint.printer import getConnectionOptions
@ -226,7 +227,8 @@ def setSettings():
plugin.on_settings_save(data["plugins"][name])
s.save()
if s.save():
eventManager().fire(Events.SETTINGS_UPDATED)
return getSettings()

View file

@ -431,12 +431,13 @@ class Settings(object):
def save(self, force=False):
if not self._dirty and not force:
return
return False
with open(self._configfile, "wb") as configFile:
yaml.safe_dump(self._config, configFile, default_flow_style=False, indent=" ", allow_unicode=True)
self._dirty = False
self.load()
return True
#~~ getter