initial commit, not much is working yet
This commit is contained in:
commit
ca9cf55756
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
|
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
*.pyc
|
||||
*.swp
|
||||
.idea
|
||||
*.iml
|
||||
build
|
||||
dist
|
||||
*.egg*
|
||||
.DS_Store
|
||||
*.zip
|
||||
*.swp
|
4
MANIFEST.in
Normal file
4
MANIFEST.in
Normal file
@ -0,0 +1,4 @@
|
||||
include README.md
|
||||
recursive-include octoprint_switcher/templates *
|
||||
recursive-include octoprint_switcher/translations *
|
||||
recursive-include octoprint_switcher/static *
|
17
README.md
Normal file
17
README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# OctoPrint-Switcher
|
||||
|
||||
**TODO:** Describe what your plugin does.
|
||||
|
||||
## Setup
|
||||
|
||||
Install via the bundled [Plugin Manager](https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager)
|
||||
or manually using this URL:
|
||||
|
||||
https://github.com/cocanut/OctoPrint-Switcher/archive/master.zip
|
||||
|
||||
**TODO:** Describe how to install your plugin, if more needs to be done than just installing it via pip or through
|
||||
the plugin manager.
|
||||
|
||||
## Configuration
|
||||
|
||||
**TODO:** Describe your plugin's configuration options (if any).
|
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:
|
||||
|
||||
switcher.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/switcher.md
Normal file
89
extras/switcher.md
Normal file
@ -0,0 +1,89 @@
|
||||
---
|
||||
layout: plugin
|
||||
|
||||
id: switcher
|
||||
title: OctoPrint-Switcher
|
||||
description: Switch gpio outputs high and low.
|
||||
author: Moritz Münch
|
||||
license: AGPLv3
|
||||
|
||||
# TODO
|
||||
date: today's date in format YYYY-MM-DD, e.g. 2015-04-21
|
||||
|
||||
homepage: https://github.com/cocanut/OctoPrint-Switcher
|
||||
source: https://github.com/cocanut/OctoPrint-Switcher
|
||||
archive: https://github.com/cocanut/OctoPrint-Switcher/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/switcher/
|
20
octoprint_switcher/__init__.py
Normal file
20
octoprint_switcher/__init__.py
Normal file
@ -0,0 +1,20 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
|
||||
class OctoSwitcherPlugin(octoprint.plugin.StartupPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
octoprint.plugin.SettingsPlugin):
|
||||
def on_after_startup(self):
|
||||
self._logger.info("Switcher settings: %s" % self._settings.get(["switch0"]))
|
||||
|
||||
def get_settings_defaults(self):
|
||||
return dict(switch0='light')
|
||||
|
||||
def get_template_vars(self):
|
||||
return dict(switch0=self._settings.get(["switch0"]))
|
||||
|
||||
__plugin_name__ = 'Switcher'
|
||||
__plugin_implementation__ = OctoSwitcherPlugin()
|
1
octoprint_switcher/static/css/switcher.css
Normal file
1
octoprint_switcher/static/css/switcher.css
Normal file
@ -0,0 +1 @@
|
||||
/* TODO: Have your plugin's CSS files generated to here. */
|
29
octoprint_switcher/static/js/switcher.js
Normal file
29
octoprint_switcher/static/js/switcher.js
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* View model for OctoPrint-Switcher
|
||||
*
|
||||
* Author: Moritz Münch
|
||||
* License: AGPLv3
|
||||
*/
|
||||
$(function() {
|
||||
function SwitcherViewModel(parameters) {
|
||||
var self = this;
|
||||
|
||||
// assign the injected parameters, e.g.:
|
||||
// self.loginStateViewModel = parameters[0];
|
||||
// self.settingsViewModel = parameters[1];
|
||||
|
||||
// TODO: Implement your plugin's view model here.
|
||||
}
|
||||
|
||||
/* view model class, parameters for constructor, container to bind to
|
||||
* Please see http://docs.octoprint.org/en/master/plugins/viewmodels.html#registering-custom-viewmodels for more details
|
||||
* and a full list of the available options.
|
||||
*/
|
||||
OCTOPRINT_VIEWMODELS.push({
|
||||
construct: SwitcherViewModel,
|
||||
// ViewModels your plugin depends on, e.g. loginStateViewModel, settingsViewModel, ...
|
||||
dependencies: [ /* "loginStateViewModel", "settingsViewModel" */ ],
|
||||
// Elements to bind to, e.g. #settings_plugin_switcher, #tab_plugin_switcher, ...
|
||||
elements: [ /* ... */ ]
|
||||
});
|
||||
});
|
1
octoprint_switcher/static/less/switcher.less
Normal file
1
octoprint_switcher/static/less/switcher.less
Normal file
@ -0,0 +1 @@
|
||||
// TODO: Put your plugin's LESS here, have it generated to ../css.
|
1
octoprint_switcher/templates/README.txt
Normal file
1
octoprint_switcher/templates/README.txt
Normal file
@ -0,0 +1 @@
|
||||
Put your plugin's Jinja2 templates here.
|
1
octoprint_switcher/templates/switcher_navbar.jinja2
Normal file
1
octoprint_switcher/templates/switcher_navbar.jinja2
Normal file
@ -0,0 +1 @@
|
||||
<a href="foo">{{ plugin_switcher_switch0|escape }}</a>
|
8
octoprint_switcher/templates/switcher_settings.jinja2
Normal file
8
octoprint_switcher/templates/switcher_settings.jinja2
Normal file
@ -0,0 +1,8 @@
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label">{{ _('Switch 0') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: settings.plugins.switcher.switch0">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
3
octoprint_switcher/test.py
Normal file
3
octoprint_switcher/test.py
Normal file
@ -0,0 +1,3 @@
|
||||
import os
|
||||
|
||||
os.system('~/switchcontrol.py getlight')
|
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 = "switcher"
|
||||
|
||||
# The plugin's python package, should be "octoprint_<plugin identifier>", has to be unique
|
||||
plugin_package = "octoprint_switcher"
|
||||
|
||||
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the
|
||||
# plugin module
|
||||
plugin_name = "OctoPrint-Switcher"
|
||||
|
||||
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
|
||||
plugin_version = "0.0.1"
|
||||
|
||||
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
||||
# module
|
||||
plugin_description = """Switch gpio outputs high and low."""
|
||||
|
||||
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
|
||||
plugin_author = "Moritz Münch"
|
||||
|
||||
# The plugin's author's mail address.
|
||||
plugin_author_email = "moritzmuench@mailbox.org"
|
||||
|
||||
# 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/cocanut/OctoPrint-Switcher"
|
||||
|
||||
# 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)
|
28
translations/README.txt
Normal file
28
translations/README.txt
Normal file
@ -0,0 +1,28 @@
|
||||
Your plugin's translations will reside here. The provided setup.py supports a
|
||||
couple of additional commands to make managing your translations easier:
|
||||
|
||||
babel_extract
|
||||
Extracts any translateable messages (marked with Jinja's `_("...")` or
|
||||
JavaScript's `gettext("...")`) and creates the initial `messages.pot` file.
|
||||
babel_refresh
|
||||
Reruns extraction and updates the `messages.pot` file.
|
||||
babel_new --locale=<locale>
|
||||
Creates a new translation folder for locale `<locale>`.
|
||||
babel_compile
|
||||
Compiles the translations into `mo` files, ready to be used within
|
||||
OctoPrint.
|
||||
babel_pack --locale=<locale> [ --author=<author> ]
|
||||
Packs the translation for locale `<locale>` up as an installable
|
||||
language pack that can be manually installed by your plugin's users. This is
|
||||
interesting for languages you can not guarantee to keep up to date yourself
|
||||
with each new release of your plugin and have to depend on contributors for.
|
||||
|
||||
If you want to bundle translations with your plugin, create a new folder
|
||||
`octoprint_switcher/translations`. When that folder exists,
|
||||
an additional command becomes available:
|
||||
|
||||
babel_bundle --locale=<locale>
|
||||
Moves the translation for locale `<locale>` to octoprint_switcher/translations,
|
||||
effectively bundling it with your plugin. This is interesting for languages
|
||||
you can guarantee to keep up to date yourself with each new release of your
|
||||
plugin.
|
Loading…
x
Reference in New Issue
Block a user