[conf] Make config reload command configurable

This commit is contained in:
Martin Muehlhaeuser 2018-08-10 15:36:35 +00:00
parent e2aaf5471c
commit a25609eea0
3 changed files with 21 additions and 6 deletions

View File

@ -55,7 +55,8 @@ class KlipperPlugin(
)]
),
configuration = dict(
path="/home/pi/printer.cfg"
path="/home/pi/printer.cfg",
reload_command="RESTART"
)
)
@ -67,7 +68,9 @@ class KlipperPlugin(
f.close()
else:
self._logger.info(
"Error: Klipper config file not found at: {}".format(self._settings.get(["config_path"]))
"Error: Klipper config file not found at: {}".format(
self._settings.get(["configuration", "path"])
)
)
return data
@ -78,14 +81,18 @@ class KlipperPlugin(
f.write(data["config"])
f.close()
self._logger.info(
"Write Klipper config to {}".format(self._settings.get(["config_path"]))
"Write Klipper config to {}".format(
self._settings.get(["configuration", "path"])
)
)
# Restart klipply to reload config
self._printer.commands("RESTART")
self._printer.commands(self._settings.get(["configuration", "reload_command"]))
self.logInfo("Reloading Klipper Configuration.")
else:
self._logger.info(
"Error: Couldn't write Klipper config file: {}".format(self._settings.get(["config_path"]))
"Error: Couldn't write Klipper config file: {}".format(
self._settings.get(["configuration", "path"])
)
)
data.pop("config", None) # we dont want to write the klipper conf to the octoprint settings
else:

View File

@ -3,7 +3,6 @@ $(function() {
function KlipperSettingsViewModel(parameters) {
var self = this;
self.settings = parameters[0];
self.klipperConfig = ko.observable();
self.addMacro = function() {
self.settings.settings.plugins.klipper.macros.push({

View File

@ -25,6 +25,15 @@
<input type="text" class="input-block-level" data-bind="value: settings.settings.plugins.klipper.configuration.path">
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Configuration Reload Command') }}</label>
<div class="controls">
<select data-bind="value: settings.settings.plugins.klipper.configuration.reload_command">
<option value="RESTART">RESTART</option>
<option value="FIRMWARE_RESTART">FIRMWARE_RESTART</option>
</select>
</div>
</div>
</div>
<div class="tab-pane" id="macros">
<div class="control-group">