Skip to content

Commit

Permalink
0.6.2
Browse files Browse the repository at this point in the history
- Added regular expression exclusion option.
  • Loading branch information
jneilliii committed Nov 25, 2019
1 parent a72e450 commit 8f857a8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
26 changes: 15 additions & 11 deletions octoprint_M117PopUp/__init__.py
Expand Up @@ -5,29 +5,33 @@

class M117PopUp(octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.SettingsPlugin):
octoprint.plugin.SettingsPlugin):

def AlertM117(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
if gcode and cmd.startswith("M117"):
self._plugin_manager.send_plugin_message(self._identifier, dict(type="popup", msg=re.sub(r'^M117\s?', '', cmd)))
return

popup_message = re.sub(r'^M117\s?', '', cmd)
if len(self._settings.get(["regex_exclude"])) > 0 and re.search(self._settings.get(["regex_exclude"]), popup_message) is not None:
return
else:
self._plugin_manager.send_plugin_message(self._identifier, dict(type="popup", msg=popup_message))
return

##-- AssetPlugin hooks
def get_assets(self):
return dict(js=["js/M117PopUp.js"])

##-- Settings hooks
def get_settings_defaults(self):
return dict(msgType="info",autoClose=True,enableSpeech=False,speechVoice="",speechVolume=1,speechPitch=1,speechRate=1)
return dict(msgType="info",autoClose=True,enableSpeech=False,speechVoice="",speechVolume=1,speechPitch=1,speechRate=1,regex_exclude="")

##-- Template hooks
def get_template_configs(self):
return [dict(type="settings",custom_bindings=True)]

##~~ Softwareupdate hook
def get_version(self):
return self._plugin_version

def get_update_information(self):
return dict(
m117popup=dict(
Expand All @@ -54,6 +58,6 @@ def __plugin_load__():

global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.comm.protocol.gcode.queuing": __plugin_implementation__.AlertM117,
"octoprint.comm.protocol.gcode.sent": __plugin_implementation__.AlertM117,
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
}
27 changes: 17 additions & 10 deletions octoprint_M117PopUp/templates/M117PopUp_settings.jinja2
Expand Up @@ -4,26 +4,33 @@
<label class="control-label">{{ _('Message Type') }}</label>
<div class="controls">
<select data-bind="options: msgTypes,optionsText: 'name',optionsValue: 'value',value: settingsViewModel.settings.plugins.M117PopUp.msgType"></select>
</div>
</div>
</div>
</div>
<div class="control-group" data-bind="visible: settingsViewModel.settings.plugins.M117PopUp.msgType() != 'disabled'">
<label class="control-label">{{ _('Auto Close') }}</label>
<div class="controls">
<input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.M117PopUp.autoClose,enabled: settingsViewModel.settings.plugins.M117PopUp.msgType() != 'disabled'">
</div>
</div>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Exclude RegEx') }}</label>
<div class="controls">
<input type="text" data-bind="value: settingsViewModel.settings.plugins.M117PopUp.regex_exclude"/>
<span class="help-inline">The regular expression is compared against the text after M117 using python's re.search so if the pattern is found anywhere in the message it will be excluded. Multiple patterns should be able to be achieved using | in the regular expression for example (LAYERINDICATOR|IGNOREME) would match LAYERINDICATOR or IGNOREME and not pop up those messages.</span>
</div>
</div>
<div class="control-group" data-bind="visible: true">
<label class="control-label">{{ _('Enable Speech') }}</label>
<div class="controls">
<input type="checkbox" data-bind="checked: settingsViewModel.settings.plugins.M117PopUp.enableSpeech">
</div>
</div>
</div>
</div>
<div class="control-group" data-bind="visible: settingsViewModel.settings.plugins.M117PopUp.enableSpeech">
<label class="control-label">{{ _('Voice') }}</label>
<div class="controls">
<select data-bind="options: voices,optionsText: 'name',optionsValue: 'value',value: settingsViewModel.settings.plugins.M117PopUp.speechVoice"></select>
</div>
</div>
</div>
</div>
<div class="control-group" data-bind="visible: settingsViewModel.settings.plugins.M117PopUp.enableSpeech">
<label class="control-label">{{ _('Volume') }}</label>
<div class="controls">
Expand Down Expand Up @@ -81,6 +88,6 @@
<div class="control-group">
<div class="controls">
<button class="btn btn-primary" data-bind="click: testPopUp">Test</button>
</div>
</div>
</div>
</div>
</form>
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -14,7 +14,7 @@
plugin_name = "OctoPrint-M117PopUp"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "0.6.1"
plugin_version = "0.6.2"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 8f857a8

Please sign in to comment.