Include config hash in SettingsUpdated event and SockJS connected message
This commit is contained in:
parent
4a49948223
commit
ff820837a5
3 changed files with 29 additions and 2 deletions
|
|
@ -285,7 +285,11 @@ def setSettings():
|
|||
logger.exception("Could not save settings for plugin {name} ({version})".format(version=plugin._plugin_version, name=plugin._plugin_name))
|
||||
|
||||
if s.save():
|
||||
eventManager().fire(Events.SETTINGS_UPDATED)
|
||||
payload = dict(
|
||||
config_hash=s.config_hash,
|
||||
effective_hash=s.effective_hash
|
||||
)
|
||||
eventManager().fire(Events.SETTINGS_UPDATED, payload=payload)
|
||||
|
||||
return getSettings()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import time
|
|||
import octoprint.timelapse
|
||||
import octoprint.server
|
||||
from octoprint.events import Events
|
||||
from octoprint.settings import settings
|
||||
|
||||
import octoprint.printer
|
||||
|
||||
|
|
@ -58,8 +59,16 @@ class PrinterStateConnection(sockjs.tornado.SockJSConnection, octoprint.printer.
|
|||
plugin_hash = hashlib.md5()
|
||||
plugin_hash.update(",".join(ui_plugins))
|
||||
|
||||
config_hash = settings().config_hash
|
||||
|
||||
# connected => update the API key, might be necessary if the client was left open while the server restarted
|
||||
self._emit("connected", {"apikey": octoprint.server.UI_API_KEY, "version": octoprint.server.VERSION, "display_version": octoprint.server.DISPLAY_VERSION, "plugin_hash": plugin_hash.hexdigest()})
|
||||
self._emit("connected", dict(
|
||||
apikey=octoprint.server.UI_API_KEY,
|
||||
version=octoprint.server.VERSION,
|
||||
display_version=octoprint.server.DISPLAY_VERSION,
|
||||
plugin_hash=plugin_hash.hexdigest(),
|
||||
config_hash=config_hash
|
||||
))
|
||||
|
||||
self._printer.register_callback(self)
|
||||
self._fileManager.register_slicingprogress_callback(self)
|
||||
|
|
|
|||
|
|
@ -544,6 +544,20 @@ class Settings(object):
|
|||
import yaml
|
||||
return yaml.safe_dump(self.effective)
|
||||
|
||||
@property
|
||||
def effective_hash(self):
|
||||
import hashlib
|
||||
hash = hashlib.md5()
|
||||
hash.update(repr(self.effective))
|
||||
return hash.hexdigest()
|
||||
|
||||
@property
|
||||
def config_hash(self):
|
||||
import hashlib
|
||||
hash = hashlib.md5()
|
||||
hash.update(repr(self._config))
|
||||
return hash.hexdigest()
|
||||
|
||||
#~~ load and save
|
||||
|
||||
def load(self, migrate=False):
|
||||
|
|
|
|||
Loading…
Reference in a new issue