OctoPrint-Estop/octoprint_estop/__init__.py

66 lines
1.9 KiB
Python
Raw Normal View History

2017-03-22 22:17:16 +01:00
# coding=utf-8
from __future__ import absolute_import
import octoprint.plugin
class EstopPlugin(octoprint.plugin.StartupPlugin,
octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.SettingsPlugin):
def get_settings_defaults(self):
return dict(
estopCommand = "M112",
estopReconnect = False)
def on_after_startup(self):
self.estopCommand = self._settings.get(["estopCommand"])
if (self.estopCommand != "M112"):
self._logger.warn("WARNING! EMERGENCY STOP COMMAND HAS BEEN CHANGED FROM DEFAULT \"M112\" TO \"" + self.estopCommand + "\"")
2017-03-22 22:17:16 +01:00
def get_assets(self):
return dict(
js=["js/estop.js"],
css=["css/estop.css"]
)
def get_template_configs(self):
return [
dict(type="sidebar", name="Emergency STOP!", icon="close", template="estop_sidebar.jinja2", styles=["display: none"], data_bind="visible: loginState.isUser"),
dict(type="settings", name="E-Stop Settings", template="estop_settings.jinja2", custom_bindings=False)
]
def on_settings_save(self, data):
s = self._settings
if "estopCommand" in data.keys():
s.set(["estopCommand"], data["estopCommand"])
if "estopReconnect" in data.keys():
s.setBoolean(["estopReconnect"], data["estopReconnect"])
s.save()
2017-04-19 17:51:09 +02:00
def get_update_information(self):
return dict(
2017-04-19 17:51:09 +02:00
estop=dict(
displayName="Emergency Stop Button",
displayVersion=self._plugin_version,
# version check: github repository
type="github_release",
user="ntoff",
repo="OctoPrint-Estop",
current=self._plugin_version,
# update method: pip
pip="https://github.com/ntoff/OctoPrint-Estop/archive/{target_version}.zip"
)
2017-04-19 17:51:09 +02:00
)
2017-03-22 22:17:16 +01:00
__plugin_name__ = "Emergency Stop Button"
def __plugin_load__():
global __plugin_implementation__
__plugin_implementation__ = __plugin_implementation__ = EstopPlugin()
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
}