Merge pull request #2802 from tedder/201809_temperature_regex_update
201809 temperature regex update
This commit is contained in:
4 files changed
+65
-3
No files matched your search
@@ -1165,7 +1165,7 @@ Use `Javascript regular expressions <https://developer.mozilla.org/en/docs/Web/J
|
||||
# A list of filters to display in the terminal tab. Defaults to the filters shown below
|
||||
terminalFilters:
|
||||
- name: Suppress temperature messages
|
||||
regex: '(Send: (N\d+\s+)?M105)|(Recv: ok T:)'
|
||||
regex: '(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+)?.*(B|T\d*):\d+)'
|
||||
- name: Suppress SD status messages
|
||||
regex: '(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)'
|
||||
- name: Suppress wait responses
|
||||
|
||||
@@ -342,7 +342,7 @@ default_settings = {
|
||||
"apps": {}
|
||||
},
|
||||
"terminalFilters": [
|
||||
{ "name": "Suppress temperature messages", "regex": "(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+)?(B|T\d*):)" },
|
||||
{ "name": "Suppress temperature messages", "regex": "(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+)?.*(B|T\d*):\d+)" },
|
||||
{ "name": "Suppress SD status messages", "regex": "(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)|(Recv: Not SD printing)" },
|
||||
{ "name": "Suppress wait responses", "regex": "Recv: wait"}
|
||||
],
|
||||
|
||||
@@ -299,7 +299,7 @@ $(function() {
|
||||
};
|
||||
|
||||
self.addTerminalFilter = function() {
|
||||
self.terminalFilters.push({name: "New", regex: "(Send: M105)|(Recv: ok T:)"})
|
||||
self.terminalFilters.push({name: "New", regex: "(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+)?.*(B|T\d*):\d+)"})
|
||||
};
|
||||
|
||||
self.removeTerminalFilter = function(filter) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import yaml
|
||||
import hashlib
|
||||
import ddt
|
||||
import time
|
||||
import re
|
||||
|
||||
import octoprint.settings
|
||||
|
||||
@@ -115,6 +116,67 @@ class TestSettings(unittest.TestCase):
|
||||
except:
|
||||
self.fail("Could not remove temporary custom basedir")
|
||||
|
||||
##~~ regexes
|
||||
def test_should_have_regex_filters(self):
|
||||
# we don't want the mocked_config, because we're testing the actual value.
|
||||
#with self.mocked_config():
|
||||
|
||||
filters = octoprint.settings.Settings().get(["terminalFilters"])
|
||||
|
||||
# we *should* have at least three, but we'll ensure there's at least one as a sanity check.
|
||||
self.assertGreater(len(filters), 0)
|
||||
|
||||
def test_should_have_suppress_temperature_regex(self):
|
||||
# we don't want the mocked_config, because we're testing the actual value.
|
||||
#with self.mocked_config():
|
||||
|
||||
filters = octoprint.settings.Settings().get(["terminalFilters"])
|
||||
temperature_regex_filters = [x for x in filters if x.get('name') == 'Suppress temperature messages']
|
||||
self.assertEqual(len(temperature_regex_filters), 1)
|
||||
|
||||
# we know there's a 'name' by now, so just ensure we have the regex key
|
||||
temperature_regex_filter = temperature_regex_filters[0]
|
||||
self.assertIn('regex', temperature_regex_filter.keys())
|
||||
|
||||
def test_temperature_regex_should_not_match(self):
|
||||
'''random entries that aren't temperature regex entries'''
|
||||
# we don't want the mocked_config, because we're testing the actual value.
|
||||
#with self.mocked_config():
|
||||
bad_terminal_entries = [
|
||||
'Send: N71667 G1 X163.151 Y35.424 E0.02043*83',
|
||||
'Send: N85343 G1 Z29.880 F10800.000*15',
|
||||
'Recv: ok',
|
||||
]
|
||||
|
||||
filters = octoprint.settings.Settings().get(["terminalFilters"])
|
||||
temperature_pattern = [x for x in filters if x.get('name') == 'Suppress temperature messages'][0]['regex']
|
||||
|
||||
matcher = re.compile(temperature_pattern)
|
||||
for terminal_string in bad_terminal_entries:
|
||||
match_result = matcher.match(terminal_string)
|
||||
# can switch to assertIsNone after 3.x upgrade.
|
||||
self.assertFalse(match_result, "string matched and it shouldn't have.")
|
||||
|
||||
|
||||
def test_temperature_regex_matches(self):
|
||||
# we don't want the mocked_config, because we're testing the actual value.
|
||||
#with self.mocked_config():
|
||||
|
||||
common_terminal_entries = [
|
||||
'Recv: ok N5993 P15 B15 T:59.2 /0.0 B:31.8 /0.0 T0:59.2 /0.0 @:0 B@:100:', # monoprice mini delta
|
||||
'Recv: ok T:210.3 /210.0 B:60.3 /60.0 T0:210.3 /210.0 @:79 B@:0 P:35.9 A:40.0', # Prusa mk3
|
||||
]
|
||||
|
||||
filters = octoprint.settings.Settings().get(["terminalFilters"])
|
||||
temperature_pattern = [x for x in filters if x.get('name') == 'Suppress temperature messages'][0]['regex']
|
||||
|
||||
matcher = re.compile(temperature_pattern)
|
||||
for terminal_string in common_terminal_entries:
|
||||
match_result = matcher.match(terminal_string)
|
||||
# can switch to assertIsNotNone after 3.x upgrade.
|
||||
self.assertTrue(match_result, "string did not match and it should have.")
|
||||
|
||||
|
||||
##~~ test getters
|
||||
|
||||
def test_get(self):
|
||||
|
||||
Reference in new issue
Block a user