🐳 chore: spelling and keyparameters
This commit is contained in:
parent
dbeb0bfcce
commit
3c940bb786
|
@ -369,6 +369,14 @@ class KlipperPlugin(
|
|||
util.update_status(self, "error", "Klipper: Error")
|
||||
logger.log_error(self, payload["error"])
|
||||
|
||||
def processAtCommand(self, comm_instance, phase, command, parameters, tags=None, *args, **kwargs):
|
||||
if command != "SWITCHCONFIG":
|
||||
return
|
||||
|
||||
config = parameters
|
||||
logger.log_info(self, "SWITCHCONFIG detected config:{}".format(config))
|
||||
return None
|
||||
|
||||
# -- GCODE Hook
|
||||
|
||||
def on_parse_gcode(self, comm, line, *args, **kwargs):
|
||||
|
@ -484,7 +492,7 @@ class KlipperPlugin(
|
|||
raise
|
||||
return NO_CONTENT
|
||||
|
||||
# Get a list of all backuped configfiles
|
||||
# Get a list of all backed up configfiles
|
||||
@octoprint.plugin.BlueprintPlugin.route("/backup/list", methods=["GET"])
|
||||
@restricted_access
|
||||
@Permissions.PLUGIN_KLIPPER_CONFIG.require(403)
|
||||
|
@ -492,7 +500,7 @@ class KlipperPlugin(
|
|||
files = cfgUtils.list_cfg_files(self, "backup")
|
||||
return flask.jsonify(files = files)
|
||||
|
||||
# restore a backuped configfile
|
||||
# restore a backed up configfile
|
||||
@octoprint.plugin.BlueprintPlugin.route("/backup/restore/<filename>", methods=["GET"])
|
||||
@restricted_access
|
||||
@Permissions.PLUGIN_KLIPPER_CONFIG.require(403)
|
||||
|
@ -571,7 +579,7 @@ class KlipperPlugin(
|
|||
Filecontent = data.get("DataToSave", [])
|
||||
saved = cfgUtils.save_cfg(self, Filecontent, filename)
|
||||
if saved == True:
|
||||
util.send_message(self, "reload", "configlist", "", "")
|
||||
util.send_message(self, type = "reload", subtype = "configlist")
|
||||
return flask.jsonify(saved = saved)
|
||||
|
||||
# restart klipper
|
||||
|
@ -634,6 +642,7 @@ def __plugin_load__():
|
|||
__plugin_hooks__ = {
|
||||
"octoprint.server.http.routes": __plugin_implementation__.route_hook,
|
||||
"octoprint.access.permissions": __plugin_implementation__.get_additional_permissions,
|
||||
"octoprint.comm.protocol.atcommand.sending": __plugin_implementation__.processAtCommand,
|
||||
"octoprint.comm.protocol.gcode.received": __plugin_implementation__.on_parse_gcode,
|
||||
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ except ImportError:
|
|||
if sys.version_info[0] < 3:
|
||||
import StringIO
|
||||
|
||||
|
||||
def list_cfg_files(self, path: str) -> list:
|
||||
"""Generate list of config files.
|
||||
|
||||
|
@ -53,6 +54,7 @@ def list_cfg_files(self, path: str) -> list:
|
|||
logger.log_debug(self, "list_cfg_files " + str(len(files)) + ": " + f)
|
||||
return files
|
||||
|
||||
|
||||
def get_cfg(self, file):
|
||||
"""Get the content of a configuration file.
|
||||
|
||||
|
@ -95,6 +97,7 @@ def get_cfg(self, file):
|
|||
response['text'] = gettext("File not found!")
|
||||
return response
|
||||
|
||||
|
||||
def save_cfg(self, content, filename):
|
||||
"""Save the configuration file to given file.
|
||||
|
||||
|
@ -138,12 +141,13 @@ def save_cfg(self, content, filename):
|
|||
logger.log_error(self, "Error: Couldn't open Klipper config file: {}".format(filepath))
|
||||
return False
|
||||
else:
|
||||
logger.log_debug(self, "Writen Klipper config to {}".format(filepath))
|
||||
logger.log_debug(self, "Written Klipper config to {}".format(filepath))
|
||||
return True
|
||||
finally:
|
||||
f.close()
|
||||
copy_cfg_to_backup(self, filepath)
|
||||
|
||||
|
||||
def check_cfg(self, data):
|
||||
"""Checks the given data on parsing errors.
|
||||
|
||||
|
@ -172,6 +176,7 @@ def check_cfg(self, data):
|
|||
logger.log_debug(self, "check_cfg: OK")
|
||||
return True
|
||||
|
||||
|
||||
def show_error_message(self, error):
|
||||
error.message = error.message.replace('\\n', '')
|
||||
if sys.version_info[0] < 3:
|
||||
|
@ -187,9 +192,14 @@ def show_error_message(self, error):
|
|||
)
|
||||
|
||||
util.send_message(
|
||||
self, 'PopUp', 'warning', 'Invalid Config data\n', ('\n' + str(error))
|
||||
self,
|
||||
type = 'PopUp',
|
||||
subtype = 'warning',
|
||||
title = 'Invalid Config data\n',
|
||||
payload = ('\n' + str(error))
|
||||
)
|
||||
|
||||
|
||||
def is_float_ok(self, dataToValidated):
|
||||
|
||||
sections_search_list = [
|
||||
|
@ -215,17 +225,18 @@ def is_float_ok(self, dataToValidated):
|
|||
)
|
||||
util.send_message(
|
||||
self,
|
||||
"PopUp",
|
||||
"warning",
|
||||
"Invalid Config data\n",
|
||||
"\n"
|
||||
+ "Invalid Value for <b>" + x + "</b> in Section: <b>" + y + "</b>\n"
|
||||
+ "{}".format(str(error))
|
||||
type = "PopUp",
|
||||
subtype = "warning",
|
||||
title = "Invalid Config data\n",
|
||||
payload = "\n"
|
||||
+ "Invalid Value for <b>" + x + "</b> in Section: <b>" + y + "</b>\n"
|
||||
+ "{}".format(str(error))
|
||||
)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def copy_cfg(self, file, dst):
|
||||
"""Copy the config file to the destination.
|
||||
|
||||
|
@ -255,6 +266,7 @@ def copy_cfg(self, file, dst):
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
def copy_cfg_to_backup(self, src):
|
||||
"""Copy the config file to backup directory of OctoKlipper.
|
||||
|
||||
|
@ -292,8 +304,6 @@ def copy_cfg_to_backup(self, src):
|
|||
)
|
||||
return False
|
||||
else:
|
||||
logger.log_debug(self, "CfgBackup " + dst + " writen")
|
||||
logger.log_debug(self, "CfgBackup " + dst + " written")
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,16 +2,32 @@ from . import util
|
|||
|
||||
def log_info(self, message):
|
||||
self._octoklipper_logger.info(message)
|
||||
util.send_message(self, "log", "info", message, message)
|
||||
util.send_message(
|
||||
self,
|
||||
type = "log",
|
||||
subtype = "info",
|
||||
title = message,
|
||||
payload = message
|
||||
)
|
||||
|
||||
def log_debug(self, message):
|
||||
self._octoklipper_logger.debug(message)
|
||||
self._logger.info(message)
|
||||
# sends a message to frontend(in klipper.js -> self.onDataUpdaterPluginMessage) and write it to the console.
|
||||
# _mtype, subtype=debug/info, title of message, message)
|
||||
util.send_message(self, "console", "debug", message, message)
|
||||
util.send_message(
|
||||
self,
|
||||
type = "console",
|
||||
subtype = "debug",
|
||||
title = message,
|
||||
payload = message
|
||||
)
|
||||
|
||||
def log_error(self, error):
|
||||
self._octoklipper_logger.error(error)
|
||||
self._logger.error(error)
|
||||
util.send_message(self, "log", "error", error, error)
|
||||
util.send_message(
|
||||
self,
|
||||
type = "log",
|
||||
subtype = "error",
|
||||
title = error,
|
||||
payload = error
|
||||
)
|
||||
|
|
|
@ -86,6 +86,7 @@ $(function () {
|
|||
|
||||
self.loadBaseConfig = function () {
|
||||
if (!self.klipperViewModel.hasRight("CONFIG")) return;
|
||||
|
||||
var baseconfig = self.settings.settings.plugins.klipper.configuration.baseconfig();
|
||||
self.klipperViewModel.consoleMessage("debug", "loadBaseConfig:" + baseconfig);
|
||||
OctoPrint.plugins.klipper.getCfg(baseconfig).done(function (response) {
|
||||
|
@ -246,8 +247,6 @@ $(function () {
|
|||
self.klipperEditorViewModel.process(config).then(
|
||||
function() { self.showEditor(); }
|
||||
);
|
||||
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
def poll_status(self):
|
||||
self._printer.commands("STATUS")
|
||||
|
||||
def update_status(self, type, status):
|
||||
send_message(self, "status", type, status, status)
|
||||
def update_status(self, subtype, status):
|
||||
send_message(
|
||||
self,
|
||||
type = "status",
|
||||
subtype = subtype,
|
||||
payload = status)
|
||||
|
||||
def file_exist(self, filepath):
|
||||
'''
|
||||
|
@ -10,8 +14,12 @@ def file_exist(self, filepath):
|
|||
'''
|
||||
from os import path
|
||||
if not path.isfile(filepath):
|
||||
send_message(self, "PopUp", "warning", "OctoKlipper Settings",
|
||||
"File: <br />" + filepath + "<br /> does not exist!")
|
||||
send_message(
|
||||
self,
|
||||
type = "PopUp",
|
||||
subtype = "warning",
|
||||
title = "OctoKlipper Settings",
|
||||
payload = "File: <br />" + filepath + "<br /> does not exist!")
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -24,7 +32,7 @@ def key_exist(dict, key1, key2):
|
|||
else:
|
||||
return True
|
||||
|
||||
def send_message(self, type, subtype, title, payload):
|
||||
def send_message(self, type, subtype, title = "", payload = ""):
|
||||
"""
|
||||
Send Message over API to FrontEnd
|
||||
"""
|
||||
|
@ -32,10 +40,10 @@ def send_message(self, type, subtype, title, payload):
|
|||
self._plugin_manager.send_plugin_message(
|
||||
self._identifier,
|
||||
dict(
|
||||
time=datetime.datetime.now().strftime("%H:%M:%S"),
|
||||
type=type,
|
||||
subtype=subtype,
|
||||
title=title,
|
||||
payload=payload
|
||||
time = datetime.datetime.now().strftime("%H:%M:%S"),
|
||||
type = type,
|
||||
subtype = subtype,
|
||||
title = title,
|
||||
payload = payload
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue