mirror of
https://github.com/Sebclem/OctoPrint-SimpleEmergencyStop.git
synced 2024-11-25 02:32:59 +01:00
Make the plugin python 3 compatible #12
This commit is contained in:
parent
dc25fd8d96
commit
021d4754a7
@ -1,33 +1,25 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
### (Don't forget to remove me)
|
|
||||||
# This is a basic skeleton for your plugin's __init__.py. You probably want to adjust the class name of your plugin
|
|
||||||
# as well as the plugin mixins it's subclassing from. This is really just a basic skeleton to get you started,
|
|
||||||
# defining your plugin as a template plugin, settings and asset plugin. Feel free to add or remove mixins
|
|
||||||
# as necessary.
|
|
||||||
#
|
|
||||||
# Take a look at the documentation on what other plugin mixins are available.
|
|
||||||
|
|
||||||
import octoprint.plugin
|
import octoprint.plugin
|
||||||
|
|
||||||
|
|
||||||
class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin,
|
class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin,
|
||||||
octoprint.plugin.TemplatePlugin,
|
octoprint.plugin.TemplatePlugin,
|
||||||
octoprint.plugin.SettingsPlugin,
|
octoprint.plugin.SettingsPlugin,
|
||||||
octoprint.plugin.AssetPlugin,
|
octoprint.plugin.AssetPlugin,
|
||||||
octoprint.plugin.SimpleApiPlugin):
|
octoprint.plugin.SimpleApiPlugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.emergencyGCODE = ""
|
self.emergencyGCODE = ""
|
||||||
|
|
||||||
|
|
||||||
def get_settings_defaults(self):
|
def get_settings_defaults(self):
|
||||||
return dict(
|
return dict(
|
||||||
emergencyGCODE="M112",
|
emergencyGCODE="M112",
|
||||||
confirmationDialog = False
|
confirmationDialog=False
|
||||||
)
|
)
|
||||||
|
|
||||||
def on_settings_save(self, data):
|
def on_settings_save(self, data):
|
||||||
octoprint.plugin.SettingsPlugin.on_settings_save(self,data)
|
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
|
||||||
self.emergencyGCODE = self._settings.get(["emergencyGCODE"])
|
self.emergencyGCODE = self._settings.get(["emergencyGCODE"])
|
||||||
|
|
||||||
def on_after_startup(self):
|
def on_after_startup(self):
|
||||||
@ -35,9 +27,9 @@ class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin,
|
|||||||
|
|
||||||
def get_template_configs(self):
|
def get_template_configs(self):
|
||||||
return [
|
return [
|
||||||
#dict(type="navbar", custom_bindings=False),
|
# dict(type="navbar", custom_bindings=False),
|
||||||
dict(type="settings", custom_bindings=False)
|
dict(type="settings", custom_bindings=False)
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_api_commands(self):
|
def get_api_commands(self):
|
||||||
return dict(
|
return dict(
|
||||||
@ -45,14 +37,14 @@ class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin,
|
|||||||
)
|
)
|
||||||
|
|
||||||
def on_api_command(self, command, data):
|
def on_api_command(self, command, data):
|
||||||
## check if there is a : in line
|
# check if there is a : in line
|
||||||
find_this = ":"
|
find_this = ":"
|
||||||
if find_this in str(self.emergencyGCODE):
|
if find_this in str(self.emergencyGCODE):
|
||||||
|
|
||||||
# if : found then, split, then for each:
|
# if : found then, split, then for each:
|
||||||
gcode_list = str(self.emergencyGCODE).split(':')
|
gcode_list = str(self.emergencyGCODE).split(':')
|
||||||
for gcode in gcode_list:
|
for gcode in gcode_list:
|
||||||
self._printer.commands(gcode)
|
self._printer.commands(gcode)
|
||||||
else:
|
else:
|
||||||
self._printer.commands(self.emergencyGCODE)
|
self._printer.commands(self.emergencyGCODE)
|
||||||
|
|
||||||
@ -62,7 +54,7 @@ class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin,
|
|||||||
js=["js/simpleemergencystop.js"],
|
js=["js/simpleemergencystop.js"],
|
||||||
)
|
)
|
||||||
|
|
||||||
##~~ Softwareupdate hook
|
# Softwareupdate hook
|
||||||
|
|
||||||
def get_update_information(self):
|
def get_update_information(self):
|
||||||
# Define the configuration for your plugin to use with the Software Update
|
# Define the configuration for your plugin to use with the Software Update
|
||||||
@ -89,6 +81,8 @@ class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin,
|
|||||||
# ("OctoPrint-PluginSkeleton"), you may define that here. Same goes for the other metadata derived from setup.py that
|
# ("OctoPrint-PluginSkeleton"), you may define that here. Same goes for the other metadata derived from setup.py that
|
||||||
# can be overwritten via __plugin_xyz__ control properties. See the documentation for that.
|
# can be overwritten via __plugin_xyz__ control properties. See the documentation for that.
|
||||||
__plugin_name__ = "Simple Emergency Stop"
|
__plugin_name__ = "Simple Emergency Stop"
|
||||||
|
__plugin_pythoncompat__ = ">=2.7,<4"
|
||||||
|
|
||||||
|
|
||||||
def __plugin_load__():
|
def __plugin_load__():
|
||||||
global __plugin_implementation__
|
global __plugin_implementation__
|
||||||
@ -98,4 +92,3 @@ def __plugin_load__():
|
|||||||
__plugin_hooks__ = {
|
__plugin_hooks__ = {
|
||||||
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
|
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user