mirror of
https://github.com/Sebclem/OctoPrint-SimpleEmergencyStop.git
synced 2024-11-22 01:02:59 +01:00
Initial Commit
This commit is contained in:
parent
daaac35389
commit
bcbe1a412e
17
.editorconfig
Normal file
17
.editorconfig
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# This file is for unifying the coding style for different editors and IDEs
|
||||||
|
# editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[**.py]
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
[**.js]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
build
|
||||||
|
dist
|
||||||
|
*.egg*
|
||||||
|
.DS_Store
|
||||||
|
*.zip
|
4
MANIFEST.in
Normal file
4
MANIFEST.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
include README.md
|
||||||
|
recursive-include octoprint_simpleemergencystop/templates *
|
||||||
|
recursive-include octoprint_simpleemergencystop/translations *
|
||||||
|
recursive-include octoprint_simpleemergencystop/static *
|
16
README.md
Normal file
16
README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Simple Emergency Stop
|
||||||
|
|
||||||
|
A simple plugin that add an Emergency stop button on the Octoprint NavBar
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Install via the bundled [Plugin Manager](https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager)
|
||||||
|
or manually using this URL:
|
||||||
|
|
||||||
|
https://github.com/BrokenFire/OctoPrint-SimpleEmergencyStop/archive/master.zip
|
||||||
|
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
- **emergencyGcode**
|
||||||
|
Diffine the GCODE to send when the button is pressed.
|
6
babel.cfg
Normal file
6
babel.cfg
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[python: */**.py]
|
||||||
|
[jinja2: */**.jinja2]
|
||||||
|
extensions=jinja2.ext.autoescape, jinja2.ext.with_
|
||||||
|
|
||||||
|
[javascript: */**.js]
|
||||||
|
extract_messages = gettext, ngettext
|
8
extras/README.txt
Normal file
8
extras/README.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Currently Cookiecutter generates the following helpful extras to this folder:
|
||||||
|
|
||||||
|
simpleemergencystop.md
|
||||||
|
Data file for plugins.octoprint.org. Fill in the missing TODOs once your
|
||||||
|
plugin is ready for release and file a PR as described at
|
||||||
|
http://plugins.octoprint.org/help/registering/ to get it published.
|
||||||
|
|
||||||
|
This folder may be safely removed if you don't need it.
|
89
extras/simpleemergencystop.md
Normal file
89
extras/simpleemergencystop.md
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
---
|
||||||
|
layout: plugin
|
||||||
|
|
||||||
|
id: simpleemergencystop
|
||||||
|
title: OctoPrint-Simpleemergencystop
|
||||||
|
description: A simple plugin that add an emergency stop buton on NavBar
|
||||||
|
author: Sebastien Clement
|
||||||
|
license: AGPLv3
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
date: 2017-07-23
|
||||||
|
|
||||||
|
homepage: https://github.com/BrokenFire/OctoPrint-SimpleEmergencyStop
|
||||||
|
source: https://github.com/BrokenFire/OctoPrint-SimpleEmergencyStop
|
||||||
|
archive: https://github.com/BrokenFire/OctoPrint-SimpleEmergencyStop/archive/master.zip
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# Set this to true if your plugin uses the dependency_links setup parameter to include
|
||||||
|
# library versions not yet published on PyPi. SHOULD ONLY BE USED IF THERE IS NO OTHER OPTION!
|
||||||
|
#follow_dependency_links: false
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
tags:
|
||||||
|
- a list
|
||||||
|
- of tags
|
||||||
|
- that apply
|
||||||
|
- to your plugin
|
||||||
|
- (take a look at the existing plugins for what makes sense here)
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
screenshots:
|
||||||
|
- url: url of a screenshot, /assets/img/...
|
||||||
|
alt: alt-text of a screenshot
|
||||||
|
caption: caption of a screenshot
|
||||||
|
- url: url of another screenshot, /assets/img/...
|
||||||
|
alt: alt-text of another screenshot
|
||||||
|
caption: caption of another screenshot
|
||||||
|
- ...
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
featuredimage: url of a featured image for your plugin, /assets/img/...
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# You only need the following if your plugin requires specific OctoPrint versions or
|
||||||
|
# specific operating systems to function - you can safely remove the whole
|
||||||
|
# "compatibility" block if this is not the case.
|
||||||
|
|
||||||
|
compatibility:
|
||||||
|
|
||||||
|
# List of compatible versions
|
||||||
|
#
|
||||||
|
# A single version number will be interpretated as a minimum version requirement,
|
||||||
|
# e.g. "1.3.1" will show the plugin as compatible to OctoPrint versions 1.3.1 and up.
|
||||||
|
# More sophisticated version requirements can be modelled too by using PEP440
|
||||||
|
# compatible version specifiers.
|
||||||
|
#
|
||||||
|
# You can also remove the whole "octoprint" block. Removing it will default to all
|
||||||
|
# OctoPrint versions being supported.
|
||||||
|
|
||||||
|
octoprint:
|
||||||
|
- 1.2.0
|
||||||
|
|
||||||
|
# List of compatible operating systems
|
||||||
|
#
|
||||||
|
# Valid values:
|
||||||
|
#
|
||||||
|
# - windows
|
||||||
|
# - linux
|
||||||
|
# - macos
|
||||||
|
# - freebsd
|
||||||
|
#
|
||||||
|
# There are also two OS groups defined that get expanded on usage:
|
||||||
|
#
|
||||||
|
# - posix: linux, macos and freebsd
|
||||||
|
# - nix: linux and freebsd
|
||||||
|
#
|
||||||
|
# You can also remove the whole "os" block. Removing it will default to all
|
||||||
|
# operating systems being supported.
|
||||||
|
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
|
- macos
|
||||||
|
- freebsd
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**TODO**: Longer description of your plugin, configuration examples etc. This part will be visible on the page at
|
||||||
|
http://plugins.octoprint.org/plugin/simpleemergencystop/
|
91
octoprint_simpleemergencystop/__init__.py
Normal file
91
octoprint_simpleemergencystop/__init__.py
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
### (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
|
||||||
|
|
||||||
|
class SimpleemergencystopPlugin(octoprint.plugin.StartupPlugin,
|
||||||
|
octoprint.plugin.TemplatePlugin,
|
||||||
|
octoprint.plugin.SettingsPlugin,
|
||||||
|
octoprint.plugin.AssetPlugin,
|
||||||
|
octoprint.plugin.SimpleApiPlugin):
|
||||||
|
def __init__(self):
|
||||||
|
self.emergencyGCODE = ""
|
||||||
|
|
||||||
|
|
||||||
|
def get_settings_defaults(self):
|
||||||
|
return dict(
|
||||||
|
emergencyGCODE="M112"
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_settings_save(self, data):
|
||||||
|
octoprint.plugin.SettingsPlugin.on_settings_save(self,data)
|
||||||
|
self.emergencyGCODE = self._settings.get(["emergencyGCODE"])
|
||||||
|
|
||||||
|
def on_after_startup(self):
|
||||||
|
self.emergencyGCODE = self._settings.get(["emergencyGCODE"])
|
||||||
|
|
||||||
|
def get_template_configs(self):
|
||||||
|
return [
|
||||||
|
#dict(type="navbar", custom_bindings=False),
|
||||||
|
dict(type="settings", custom_bindings=False)
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_api_commands(self):
|
||||||
|
return dict(
|
||||||
|
emergencyStop=[]
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_api_command(self, command, data):
|
||||||
|
self._printer.commands(self.emergencyGCODE)
|
||||||
|
|
||||||
|
def get_assets(self):
|
||||||
|
|
||||||
|
return dict(
|
||||||
|
js=["js/simpleemergencystop.js"],
|
||||||
|
)
|
||||||
|
|
||||||
|
##~~ Softwareupdate hook
|
||||||
|
|
||||||
|
def get_update_information(self):
|
||||||
|
# Define the configuration for your plugin to use with the Software Update
|
||||||
|
# Plugin here. See https://github.com/foosel/OctoPrint/wiki/Plugin:-Software-Update
|
||||||
|
# for details.
|
||||||
|
return dict(
|
||||||
|
simpleemergencystop=dict(
|
||||||
|
displayName="Simple Emergency Stop",
|
||||||
|
displayVersion=self._plugin_version,
|
||||||
|
|
||||||
|
# version check: github repository
|
||||||
|
type="github_release",
|
||||||
|
user="BrokenFire",
|
||||||
|
repo="OctoPrint-SimpleEmergencyStop",
|
||||||
|
current=self._plugin_version,
|
||||||
|
|
||||||
|
# update method: pip
|
||||||
|
pip="https://github.com/BrokenFire/OctoPrint-SimpleEmergencyStop/archive/{target_version}.zip"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# If you want your plugin to be registered within OctoPrint under a different name than what you defined in setup.py
|
||||||
|
# ("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.
|
||||||
|
__plugin_name__ = "Simple Emergency Stop"
|
||||||
|
|
||||||
|
def __plugin_load__():
|
||||||
|
global __plugin_implementation__
|
||||||
|
__plugin_implementation__ = SimpleemergencystopPlugin()
|
||||||
|
|
||||||
|
global __plugin_hooks__
|
||||||
|
__plugin_hooks__ = {
|
||||||
|
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* View model for OctoPrint-Simpleemergencystop
|
||||||
|
*
|
||||||
|
* Author: Sebastien Clement
|
||||||
|
* License: AGPLv3
|
||||||
|
*/
|
||||||
|
$(function() {
|
||||||
|
function SimpleemergencystopViewModel(parameters) {
|
||||||
|
var self = this;
|
||||||
|
self.loginState = parameters[1];
|
||||||
|
self.printerState = parameters[2];
|
||||||
|
console.log(parameters);
|
||||||
|
self.click = function () {
|
||||||
|
$.ajax({
|
||||||
|
url: API_BASEURL+"plugin/simpleemergencystop",
|
||||||
|
type: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
data: JSON.stringify({
|
||||||
|
command: "emergencyStop"
|
||||||
|
}),
|
||||||
|
contentType: "application/json; charset=UTF-8",
|
||||||
|
success: function (data,status) {
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// view model class, parameters for constructor, container to bind to
|
||||||
|
OCTOPRINT_VIEWMODELS.push([
|
||||||
|
SimpleemergencystopViewModel,
|
||||||
|
|
||||||
|
["settingsViewModel","loginStateViewModel","printerStateViewModel"],
|
||||||
|
|
||||||
|
["#navbar_plugin_simpleemergencystop"]
|
||||||
|
]);
|
||||||
|
});
|
@ -0,0 +1,4 @@
|
|||||||
|
<a data-bind="click: click, visible: loginState.isUser && printerState.isOperational" href="#">
|
||||||
|
<i class="icon-warning-sign" style="color: red"></i>
|
||||||
|
</a>
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
<form class="form-horizontal">
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label">{{ _('Emergency GCODE:') }}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="input-block-level" data-bind="value: settings.plugins.simpleemergencystop.emergencyGCODE">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
9
requirements.txt
Normal file
9
requirements.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
###
|
||||||
|
# This file is only here to make sure that something like
|
||||||
|
#
|
||||||
|
# pip install -e .
|
||||||
|
#
|
||||||
|
# works as expected. Requirements can be found in setup.py.
|
||||||
|
###
|
||||||
|
|
||||||
|
.
|
96
setup.py
Normal file
96
setup.py
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
|
||||||
|
########################################################################################################################
|
||||||
|
### Do not forget to adjust the following variables to your own plugin.
|
||||||
|
|
||||||
|
# The plugin's identifier, has to be unique
|
||||||
|
plugin_identifier = "simpleemergencystop"
|
||||||
|
|
||||||
|
# The plugin's python package, should be "octoprint_<plugin identifier>", has to be unique
|
||||||
|
plugin_package = "octoprint_simpleemergencystop"
|
||||||
|
|
||||||
|
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the
|
||||||
|
# plugin module
|
||||||
|
plugin_name = "OctoPrint-SimpleEmergencyStop"
|
||||||
|
|
||||||
|
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
|
||||||
|
plugin_version = "0.1.0"
|
||||||
|
|
||||||
|
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
||||||
|
# module
|
||||||
|
plugin_description = """A simple plugin that add an emergency stop buton on NavBar"""
|
||||||
|
|
||||||
|
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
|
||||||
|
plugin_author = "Clément Sébastien"
|
||||||
|
|
||||||
|
# The plugin's author's mail address.
|
||||||
|
plugin_author_email = "seb6596@gmail.com"
|
||||||
|
|
||||||
|
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module
|
||||||
|
plugin_url = "https://github.com/BrokenFire/OctoPrint-SimpleEmergencyStop"
|
||||||
|
|
||||||
|
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module
|
||||||
|
plugin_license = "AGPLv3"
|
||||||
|
|
||||||
|
# Any additional requirements besides OctoPrint should be listed here
|
||||||
|
plugin_requires = []
|
||||||
|
|
||||||
|
### --------------------------------------------------------------------------------------------------------------------
|
||||||
|
### More advanced options that you usually shouldn't have to touch follow after this point
|
||||||
|
### --------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Additional package data to install for this plugin. The subfolders "templates", "static" and "translations" will
|
||||||
|
# already be installed automatically if they exist. Note that if you add something here you'll also need to update
|
||||||
|
# MANIFEST.in to match to ensure that python setup.py sdist produces a source distribution that contains all your
|
||||||
|
# files. This is sadly due to how python's setup.py works, see also http://stackoverflow.com/a/14159430/2028598
|
||||||
|
plugin_additional_data = []
|
||||||
|
|
||||||
|
# Any additional python packages you need to install with your plugin that are not contained in <plugin_package>.*
|
||||||
|
plugin_additional_packages = []
|
||||||
|
|
||||||
|
# Any python packages within <plugin_package>.* you do NOT want to install with your plugin
|
||||||
|
plugin_ignored_packages = []
|
||||||
|
|
||||||
|
# Additional parameters for the call to setuptools.setup. If your plugin wants to register additional entry points,
|
||||||
|
# define dependency links or other things like that, this is the place to go. Will be merged recursively with the
|
||||||
|
# default setup parameters as provided by octoprint_setuptools.create_plugin_setup_parameters using
|
||||||
|
# octoprint.util.dict_merge.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# plugin_requires = ["someDependency==dev"]
|
||||||
|
# additional_setup_parameters = {"dependency_links": ["https://github.com/someUser/someRepo/archive/master.zip#egg=someDependency-dev"]}
|
||||||
|
additional_setup_parameters = {}
|
||||||
|
|
||||||
|
########################################################################################################################
|
||||||
|
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
try:
|
||||||
|
import octoprint_setuptools
|
||||||
|
except:
|
||||||
|
print("Could not import OctoPrint's setuptools, are you sure you are running that under "
|
||||||
|
"the same python installation that OctoPrint is installed under?")
|
||||||
|
import sys
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
|
setup_parameters = octoprint_setuptools.create_plugin_setup_parameters(
|
||||||
|
identifier=plugin_identifier,
|
||||||
|
package=plugin_package,
|
||||||
|
name=plugin_name,
|
||||||
|
version=plugin_version,
|
||||||
|
description=plugin_description,
|
||||||
|
author=plugin_author,
|
||||||
|
mail=plugin_author_email,
|
||||||
|
url=plugin_url,
|
||||||
|
license=plugin_license,
|
||||||
|
requires=plugin_requires,
|
||||||
|
additional_packages=plugin_additional_packages,
|
||||||
|
ignored_packages=plugin_ignored_packages,
|
||||||
|
additional_data=plugin_additional_data
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(additional_setup_parameters):
|
||||||
|
from octoprint.util import dict_merge
|
||||||
|
setup_parameters = dict_merge(setup_parameters, additional_setup_parameters)
|
||||||
|
|
||||||
|
setup(**setup_parameters)
|
Loading…
Reference in New Issue
Block a user