Merge branch 'maintenance' into devel

This commit is contained in:
Gina Häußge committed 2021-02-24 15:04:22 +01:00
commit 5b7bc6cb91
11 files changed
+112 -39

No files matched your search

@@ -45,8 +45,9 @@ class GcodeviewerPlugin(
def get_settings_defaults(self):
return {
"mobileSizeThreshold": 2 * 1024 * 1024, # 2MB
"sizeThreshold": 20 * 1024 * 1024,
} # 20MB
"sizeThreshold": 20 * 1024 * 1024, # 20MB
"skipUntilThis": None,
}
def get_settings_version(self):
return 1
@@ -475,6 +475,20 @@ $(function () {
};
self.showGCodeViewer = function (response, rstatus) {
// Slice of the gcode
var findThis = self.settings.settings.plugins.gcodeviewer.skipUntilThis();
if (findThis && findThis !== "") {
var indexPos = response.indexOf("\n" + findThis);
// Try windows newlines if not found
if (indexPos === -1) {
indexPos = response.indexOf("\r" + findThis);
}
if (indexPos !== -1) {
// Slice and make sure we comment out any string left back after slicing - so if a user configures something like "G1" we dont end up with a snippet of gcode commands
// Yes it would be prettier to parse it line by line and remove the entire line, that is very slow and uses mem - this way we find the string, and remove it
response = ";" + response.slice(indexPos + findThis.length + 1);
}
}
var par = {
target: {
result: response
@@ -19,4 +19,15 @@
</span>
</div>
</div>
<div class="control-group" title="{{ _('Skip/Hide gcode until this string')}}">
<label class="control-label" for="settings-skipUntilThis">{{ _('Skip to this') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settings.settings.plugins.gcodeviewer.skipUntilThis" id="settings-skipUntilThis" placeholder="; layer 1">
</div>
<div class="controls">
<span class="help-inline">
{% trans %}If provided, the GCode Viewer will search for a line beginning with this string. If found, all GCode up to that point will be skipped. This can be used to skip "purge/nozzle wipe" GCode in the viewer. Note the search is case sensitive. Example: <code>; layer 1</code>{% endtrans %}
</span>
</div>
</div>
</form>
+6 -2
View File
@@ -169,7 +169,7 @@ Groups will be as follows:
* ``value``: reported position value
"""
regex_firmware_splitter = re.compile(r"\s*([A-Z0-9_]+):\s*")
regex_firmware_splitter = re.compile(r"(^|\s+)([A-Z][A-Z0-9_]*):")
"""Regex to use for splitting M115 responses."""
regex_resend_linenumber = re.compile(r"(N|N:)?(?P<n>%s)" % regex_int_pattern)
@@ -6074,6 +6074,10 @@ def parse_firmware_line(line):
The result will be a dictionary mapping from the contained keys to the contained
values.
Valid keys must only contain A-Z, 0-9 and _ and must start with a letter. See the
unit tests for valid and invalid examples. There sadly is no existing specification
of the key format, but this is the format extracted from real life logs.
Arguments:
line (str): the line to parse
@@ -6091,7 +6095,7 @@ def parse_firmware_line(line):
split_line = regex_firmware_splitter.split(line.strip())[
1:
] # first entry is empty start of trimmed string
for key, value in chunks(split_line, 2):
for _, key, value in chunks(split_line, 3):
result[key] = value.strip()
return result